Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery ui autocomplete needs additional function
    text
    copied!<p>I have such autocomplete code:</p> <pre><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); } }); } </code></pre> <p>});</p> <p>When i try to get data Firebug shows an error: <em>"updateSpotList is not defined"</em>. I need to creat a function called <em>updateSpotList</em> to get response from the server. And the success alert is never invoked.</p> <p>Why do i need this function? Maybe there are something defined in aspx? It is:</p> <pre><code>string response = ""; string callback = Request.QueryString["c"]; string action = Request.QueryString["a"]; string query = Request.QueryString["q"]; //Ensure action parameter is set if(action != null &amp;&amp; action.Equals("getspots")){ //Ensure query parameter is set if (query != null &amp;&amp; query.Length &gt; 0){ SpotListRequest request = new SpotListRequest { FreeText = query, Language = "sv-SE" }; IEnumerable&lt;Spot&gt; spots = DataBridge.GetSpotList(null, null, query).OrderBy(i =&gt; i.FullName); JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(spots.ToArray()); //Ensure callback parameter is set if (callback != null &amp;&amp; callback.Length &gt; 0) { response = String.Format("{0}('{1}')", callback, json); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload