on Autocomplete, call ashx page to get data
-
I was not very sure where to post this. Found aspx and httphandler related to asp.net so posted here. I have used JQuery to call autocomplete on a textbox1 as below:
$("input#textbox1").autocomplete({
source: ["India", "Japan", "United Kingdom", "United States", "Australia", "France", "China"]
});This works fine. When i try to change this to
$("input#textbox1").autocomplete('GenericHandler.ashx');
, the 'GenericHandler.ashx' never gets called. In ProcessRequest method of GenericHandler, i have written
context.Response.Write("India|Japan|United Kingdom|United States|Australia|France|China");
I have included appropriate verb in web.config for caller. How do i achieve the autocomplete calling ashx and then getting data to fill ? Please help. note: I am using jquery-ui.min.js for AutoComplete.
-
I was not very sure where to post this. Found aspx and httphandler related to asp.net so posted here. I have used JQuery to call autocomplete on a textbox1 as below:
$("input#textbox1").autocomplete({
source: ["India", "Japan", "United Kingdom", "United States", "Australia", "France", "China"]
});This works fine. When i try to change this to
$("input#textbox1").autocomplete('GenericHandler.ashx');
, the 'GenericHandler.ashx' never gets called. In ProcessRequest method of GenericHandler, i have written
context.Response.Write("India|Japan|United Kingdom|United States|Australia|France|China");
I have included appropriate verb in web.config for caller. How do i achieve the autocomplete calling ashx and then getting data to fill ? Please help. note: I am using jquery-ui.min.js for AutoComplete.
hi RaviSant, As far as i know, u can use JSON format to return ur result from
ashx
file. and in the .autocomplete
use options as parameter. like this.var options, a;
jQuery(function(){
options = { serviceUrl:'GenericHandler.ashx' };
a = $('#query').autocomplete(options);
});and in the web service class, return the
JSON
format like this.{
query:'Li',
suggestions:['India', 'Japan', 'United Kingdom', 'United States', 'Australia', 'France', 'China'],
data:['IN','JP','UK','US','AZ','FR','CH']
}query
is the entered search keysuggestions
is the list to display in dropdowndata
is optional to use as value field when u select suggestion data from dropdown text To know more about JSON,here[^] To learn how to return JSON format fromashx
, here[^] Ref: I get this code from devbridge.com[^] Hope this works!Please give any idea or suggestion on my advice.