I have created an "
usercontrol" which will accept the zip code and display state and city(returning in json format).
So I have written keyup function for zipcode textbox in javacript.
In javascript side, I want to call the webservice.
Here is my code written in the
ascx page:
function OnKeyUP(s, e) {
var len = txtZip.GetText();
var newstring = len.replace(/[_-]/g, '');
if (newstring.length == 5) {
$.ajax(
{
type: "POST",
url: '~/CityStateZipCodes.asmx/GetCityStateZipCodes',
data: "{'zip':'77853'}",
async: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
},
error: function () {
alert('error');
}
});
}
}
But I am unable to call the webservice, can someone please help me out how to call, or give an example.