Take the 2-minute tour ×

Good day,

I've got WebMethod that looks a bit like this...

    public static string ProcessItem(Item item, ItemStatus 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) {
            type: 'POST',
            url: 'ProcessPO.aspx/ProcessItem',
            data: JSON.stringify(dto) + status',
            dataType: 'json',
            success: function (msg) {
                if (msg.d)
            error: function (xhr, status, errorThrown) {

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 };
share|improve this question

1 Answer 1

up vote 2 down vote accepted
var d = JSON.Stringify(dto);
d.status = status;

Then in the ajax call

data: d

Also by looking at your code you may want to return a JsonResult.

return Json(new {Success=true}); //Success
return Json(new {Success=false, Message = ex.Message}); //Failure

//if it is a get request
return Json(new {Success=true}, JsonRequestBehavior.AllowGet) //Success
return Json(new {Success=false, Message = ex.Message}, JsonRequestBehavior.AllowGet) //Failure

This will allow you to see the result of the method in the javascript.

success: function(response){
        alert('Failure! ' + response.Message);
share|improve this answer
Looks like it's working but now I have other issues to work out. Thanks for the quick response! –  Shane LeBlanc May 8 '12 at 23:09
i added some more for you. it should allow you to do what you want by looking at what you were trying with your code –  Rob May 8 '12 at 23:32

Your Answer


