Node js JQuery Opening a new webpage just like happens in the dictionaries

☆樱花仙子☆ 提交于 2020-01-03 04:34:28

问题


I want to make a nodejs, expressjs and jquery search bar which shows article titles and then opens a related webpage in order to selecting the word. My code is:

        form.form-inline.my-2.my-lg-0
      input.form-control.mr-sm-2(id="tags", type='text', placeholder='Search', aria-label='Search')
      button.btn.btn-secondary.my-2.my-sm-0(type='submit') 

And my autocomplete.js file is here also:

    $('#tags').autocomplete({
  source: function(req,res) {
      $.ajax({
          url: "http://localhost:3000/",
          dataType: "jsonp",
          type: "GET",
          data: {
              term: article.title //I am not sure
          },
          success: function(data) {
              res($.map(data, function(item) {
                  return {
                      label: article.title,//text comes from a collection of mongo
                  };
              }));
          },
          error: function(xhr) {
              alert(xhr.status + ' : ' + xhr.statusText);
          }
      });
  },
  select: function(event, ui) {
    window.location.replace("/article/" + ui.item.id);
  }
});

Can you solve this problem.

来源:https://stackoverflow.com/questions/59567352/node-js-jquery-opening-a-new-webpage-just-like-happens-in-the-dictionaries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!