i have such autocomplete code:
  $("input#pickupspot").autocomplete({   source: function(request, response){      $.ajax({         url: "ajaxsearch.aspx",         datatype: "jsonp",         data: {            a: "getspots",            c: "updatespotlist",            q: request.term         },         success: function(){            alert("success");         },         error: function (xhr, ajaxoptions, thrownerror){                 alert(xhr.status);                 alert(thrownerror);         }       });   } 
  });
  when try data firebug shows error: "updatespotlist not defined".  need creat function called updatespotlist response server. , success alert never invoked.
  why need function? maybe there defined in aspx? is:
  string response = "";   string callback = request.querystring["c"];  string action = request.querystring["a"];   string query = request.querystring["q"];    //ensure action parameter set   if(action != null && action.equals("getspots")){         //ensure query parameter set         if (query != null && query.length > 0){             spotlistrequest request = new spotlistrequest             {                 freetext = query,                 language = "sv-se"             };             ienumerable<spot> spots = databridge.getspotlist(null, null, query).orderby(i => i.fullname);              javascriptserializer js = new javascriptserializer();              string json = js.serialize(spots.toarray());              //ensure callback parameter set             if (callback != null && callback.length > 0)             {                 response = string.format("{0}('{1}')", callback, json);             }         }     } 
        
  you can specify url source parameter, instead of data parameter.
  http://jqueryui.com/demos/autocomplete/#option-source
  the plugin make request server, , should return json array looking this:
  [{label: "name"}, {label: "name 2"}]
  change javascript code this:
  $("input#pickupspot").autocomplete({   source: "ajaxsearch.aspx?a=getspots&c=updatespotlist" }); 
  the autocomplete plugin append parameter named term source url, current value of input element, request made to: "ajaxsearch.aspx?a=getspots&c=updatespotlist&term=test" if wrote test in input element.
  on server, want change q term.
       
   
Comments
Post a Comment