douguanyan9928 2018-06-15 02:36
浏览 105
已采纳

在HTML页面上使用Golang进行实时搜索

I'd like to run a search and display its results as soon as the text of an <input> changes.

How could the program get the value from the <input> when it changes?

<input type="text" name="search" id="search">
<section id="results"></section>
  • 写回答

1条回答 默认 最新

  • dongmu1914 2018-06-15 03:20
    关注

    Post you value to Golang with ajax.

    $("input").keyup(function(){
    txt=$("input").val();
    $.post("url",{suggest:txt},function(result){
         $("#results").html(result);
         });
       });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?