I am doing simple save operation (Code is as per tutorial)
...but ajax is not sending json data to save method
on Firebug console it displays following Error:
"NetworkError: 500 Internal Server Error - http://localhost/WebApplication2/WebForm1.aspx/saveData"
(Note: My libraries are updated and properly placed.)
ajax
var name = "neeraj";
var gender = "male";
$.ajax({
type: "POST",
url: "WebForm1.aspx/saveData",
data: { 'name': JSON.stringify(name), 'Gender': JSON.stringify(gender) },
contentType: "application/json;charset=utf-8",
dataType: "JSON",
async: "true",
success: function (response) {
alert('success');
}
});
My page url is
../WebApplication2/WebForm1.aspx
save method(webform1.aspx.cs)
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static int saveData(string name, string Gender)
{ return 1;}
Similar Posts:
Returning Response in jquery ajax function
it suggest to use datatype:"JSON" instead of "jsondata" ...I already haveajax jquery post method
it suggests to created a seperate webservice for save method in stead of cs fileAJAX to web method not returning JSON
it suggest to put
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
on WebMethod .. I already didSend JSON with Ajax to ASP.NET Web Method
it suggest to use JSON.stringify ... this is also not working