Good day,
I’ve got WebMethod that looks a bit like this…
[WebMethod]
public static string ProcessItem(Item item, ItemStatus status)
{
try
{
item.Process(status);
return "Success!";
}
catch (Exception ex)
{
return ex.Message;
}
}
And I’ve got an jQuery method that looks a bit like this…
function Process(dto, status) {
$.ajax({
type: 'POST',
url: 'ProcessPO.aspx/ProcessItem',
data: JSON.stringify(dto) + status',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
if (msg.d)
alert('success');
},
error: function (xhr, status, errorThrown) {
alert(xhr.responseText);
}
});
}
In the data: line, how do I concatenate the two so they’re passed in properly?
The dto is defined like this…
var dto = { 'item': item };
Then in the ajax call
Also by looking at your code you may want to return a JsonResult.
This will allow you to see the result of the method in the javascript.