mercredi 6 mai 2015

Is it possible to make ajax call from .ascx page. here is my code please review

This is from .ascx page, here i am calling .autocomplete inside this i am colling ajax call. please help.

                            $("#txtUsers").autocomplete({
                                        //source: availableTags
                                        source: function (request, response) {
                                            //Pass the selected country to the query manager to limit the selection to 1 country
                                            $.ajax({
                                                url: 'http://ift.tt/1F5oJKK',
                                                data: '{Name:' + $('#txtUsers').val() + '}',
                                                type: 'POST', // a jQuery ajax POST transmits in querystring format (key=value&key1=value1) in utf-8
                                                dataType: 'json', //return data in json format
                                                success: function (data) {
                                                    response($.map(data, function (item) {
                                                        return {
                                                            label: item.stateName,
                                                            value: item.name
                                                            //abbrev: item.stateAbbrev
                                                        };
                                                    }));
                                                }
                                            });
                                        }
                                    });

on .cs page:

[WebMethod]
public static string GetNames(string Name)
{
    return "";
}

Aucun commentaire:

Enregistrer un commentaire