I want to create a web method that accepts a List of custom objects (passed in via jQuery/JSON).
When I run the website locally everything seems to work. jQuery an
Alright, here's how it is for an object, just tested this: ============================================ASPX==================================
$("#btngeMethodCallWithAnObjectAsAParameter").click(function (event) {
$.ajax({
type: 'POST',
url: 'Default.aspx/PageMethodCallWithAnObjectAsAParameter',
data: '{"id":"' + '5' + '", "jSonAsset":' + JSON.stringify(new BuildJSonAsset()) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d) {
alert(msg.d);
}
},
error: function () {
alert("Error! Try again...");
}
});
});
});
function BuildJSonAsset() {
this.AssetId = '100';
this.ContentId = '200';
this.AssetName = 'Asset1';
}
========================================================================
[WebMethod()]
public static string PageMethodCallWithAnObjectAsAParameter(int id, JSonAsset jSonAsset)
{
return "Success!";
}
======================================================================
And this works for a single object, next I am going to try a list of objects:)