I tried this page method code in my ASPX page (ShowUsers.aspx), but the function gave me a 500
server error and does not go in to the success
handler.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetInfo(string email)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
User user = UserService.GetUser(email);
return jss.Serialize(user);
}
And the JavaScript:
$(document).ready(function() {
$("#l").click(function() {
$("#modalUpdate").fadeIn(1000);
var url = "ShowUsers.aspx/GetInfo";
var email = "davidizhakinew@gmail.com";
$.ajax({
url: url,
type: "POST",
data: "{ email : " + email + " }",
dataType: "JSON",
contentType: "application/JSON; charset=utf-8",
success: function(msg) {
alert("success");
var data = JSON.parse(msg.d);
// do stuff (trimmed)
},
error: function(msg, xhr) {
alert(msg + ", " + xhr.responseText);
}
});
});
});
Can someone help me please?