Review: Ajax POST to C# WebMethod

[WebMethod]
public static void testingWebMethod(Object dataTest)
{
Debug.WriteLine(dataTest);

Debug.WriteLine(dataTest);
}

 

var sendThisData = JSON.stringify({
dataTest: [{ "name": "foo" }]
});
$.ajax({
type: "POST",
url: "page.aspx/testingWebMethod",
data: sendThisData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
},
error: function () {
alert("Something went wrong.");
}
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s