douguanyan9928
2018-06-15 02:36
浏览 103

在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);
         });
       });
    
    打赏 评论

相关推荐 更多相似问题