javascript - Autocomplete not working when added space -


in project, trying create autocomplete effect using following plugin:

devbridge jquery autocomplete

this plugin working fine until don't add space textbox (after adding word). , when delete entered word using backspace autocomplete showing previous list should have shown before.

ps: every time passing full text of text field server through ajax call necessary in application.

here code:

js fiddle (not working because of ajax url)

js

$(function () {      var result = $('#result');     var contents = {         value: "",         data: ""     };     /* ajax call */     result.keydown(function (event) {         if (!event.shiftkey) {             var sugdata;             var text = result.val(); //.split(" ").pop();             //console.log(text);             /* send data using post , put results in div */             $.ajax({                 url: "http://localhost:9999/projects/1/autocomplete/suggestions",                 type: "post",                 data: "drqlfragment=" + text, // + "  ",                 //data: "drqlfragment=when node_database_property  ",                 async: false,                 cache: false,                 headers: {                     accept: "application/json",                     contenttype: "application/x-www-form-urlencoded"                 },                 contenttype: "application/x-www-form-urlencoded",                 processdata: true,                 success: function (data, textstatus, jqxhr) {                     var resdata = data.suggestions;                     //console.dir(resdata);                     (var = 0; < resdata.length; i++) {                         resdata[i].value = resdata[i].keyword;                     }                     sugdata = resdata;                     //console.dir(sugdata);                 },                 error: function (response) {                     //console.dir(response);                     $("#result").val('there error while submit');                 }             });             console.dir(sugdata);             $('#result').autocomplete({                 lookup: sugdata             });         }     }); }); 

html

<form id="foo">     <textarea id="result" rows="4" cols="50"></textarea>     <input type="submit" value="send" /> </form> 

sorry, can't provide json data because being modified server whenever press key. (so, object variable returning server on ajax call).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -