i am learning Jquery Ajax method. i try to post one json string , it working using $.post method but not working in $.Ajax method . it is giving 500 error.please give some suggession
---- $.post--- method // working
$.post("About.aspx?type=Test", { 'Data': '[{"Key":"454","Value":["1","3"]},{"Key":"496","Value":["1","2","3"]}]' }, function (result) {
alert(result.d);
});
----c#-----
public void add()
{
string value = Request.Form["Data"];
}
------$.Ajax post--------- method // Not working. but if i am passing data as "{'data':'1'}"--working
$.ajax({
type: "POST",
url: "Contact.aspx/add",
dataType: "json",
data: "{'Data': '[{'Key':'454','Value':['1','3']},{'Key':'496','Value':['1','2','3']}]'}",
contentType: "application/json; charset=utf-8",
success: function (response) {
},
error: function (msg) {
alert(msg.status);
}
});
-----c#----
[WebMethod]
public static void add( string Data)
{
}