I have jQuery code to get JSON from the server:
$(document).ready(function () {
$.getJSON('Default2.aspx/GetPerson', { 'firstname': 'brian', 'lastname': 'lee' }, function (response) {
alert(response.Age);
});
});
Default2.aspx code :
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static String GetPerson(String firstname, String lastname)
{
Person p = new Person(firstname, lastname);
return "{\"Age\":\"12\"}";
}
The question is :
Why GetPerson
method is not called from my script? I attach the debugger in GetPerson
but it seems doesn't called.
Any help would be appreciate!