Browse Source

提交代码,重定向

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 4 years ago
parent
commit
50284474d5
2 changed files with 6 additions and 13 deletions
  1. +5
    -12
      public/home/search.js
  2. +1
    -1
      routers/search.go

+ 5
- 12
public/home/search.js View File

@@ -189,20 +189,13 @@ function initDiv(isSearchLabel=false){

function searchLabel(tableName,keyword,sortBy="",ascending="false"){

var httpRequest = new XMLHttpRequest();//第一步:创建需要的对象
httpRequest.open('POST', '/all/search/', true); //第二步:打开连接
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");//设置请求头 注:post方式必须设置请求头(在建立连接后设置请求头)
httpRequest.send("q=" + keyword + "&tableName=" + tableName + "&searchLabel=true");//发送请求 将情头体写在send中
httpRequest.onreadystatechange = function () {//请求后的回调接口,可将请求成功后要执行的程序写在其中
if (httpRequest.readyState == 4 && httpRequest.status == 200) {//验证请求是否发送成功
var json = httpRequest.responseText;//获取到服务端返回的数据
console.log(json);
}
};

sessionStorage.setItem("keyword",keyword);
sessionStorage.setItem("tableName",tableName);
sessionStorage.setItem("searchLabel",true);

console.log("enter label search.");

window.location.href="/all/search/"
// initDiv(true);
// //document.getElementById("search_div").style.display="none";
// //document.getElementById("search_label_div").style.display="block";


+ 1
- 1
routers/search.go View File

@@ -36,7 +36,7 @@ func InitESClient() {
func EmptySearch(ctx *context.Context) {
log.Info("search template.")
ctx.Data["Keyword"] = ""
Home(ctx)
ctx.HTML(200, "explore/search_new")
}

func Search(ctx *context.Context) {


Loading…
Cancel
Save