javascript - Autocomplete returns an error on ajax request -
i trying utilize jquery autocomplete on text box, it's not working.
here script autocomplete list database gives me error , alerts error message.
$(function () { $("#contentplaceholdersearch_txt_search").autocomplete({ source: function (request, response) { $.ajax({ url: "service/autocomplete.asmx/getcompletionlistname", data: "{ 'prefixtext': '" + request.term + "' }", datatype: "json", type: "post", contenttype: "application/json; charset=utf-8", datafilter: function (data) { homecoming data; }, success: function (data) { response($.map(data.d, function (item) { homecoming { value: item } })) }, error: function (xmlhttprequest, textstatus, errorthrown) { alert(textstatus); } }); }, minlength: 2 }); });
here server code
[webmethod] public string[] getcompletionlistname(string prefixtext, int count) { list<string> items = new list<string>(count); ga_userstableadapter uta = new ga_userstableadapter(); usercontrollar.ga_usersdatatable udt = uta.getdatabynameautocomplete(prefixtext); foreach (datarow row in udt.rows) { items.add(row["full_name"].tostring()); } homecoming items.toarray(); }
i changed service path in script from
url: "service/autocomplete.asmx/getcompletionlistname"
to
url: "../service/autocomplete.asmx/getcompletionlistname"
and works now...
javascript c# jquery asp.net ajax
No comments:
Post a Comment