views:

18

answers:

0

I have a javascript class that's as below

function paramObj(test_id,uid,qid,ai) 
{
    this.test_id = test_id;
    this.uid = uid;
    this.question_id = qid;
    this.ansIndex = ai;
}

I fill an array with several of these objects and send them to my ASP.NET C# WebMethod defined as

    [WebMethod()]
    [System.Web.Script.Services.ScriptMethod()]
    public static string _doSubmit(JSONObj obj)
    {
        return ("ok");
    }

The jQuery ajax call is

 $.ajax(
    {
        type: 'POST',
        url: 'TestScreen_rev2.aspx/_doSubmit',
        data: JSON.stringify({'submit':arrayOfResp}),
        contentType: "application/json; charset=utf-8",
        dataType: 'json',
        success: function (msg)
        {
            alert(msg.d);
        },
        error: function (e)
        {
            alert('error = ' + e.statusText);
        }
    });

The JSON.stringify seems to be fine, for e.g. here's a output

[{"test_id":6,"uid":3,"question_id":51,"ansIndex":0},{"test_id":6,"uid":3,"question_id":56,"ansIndex":2}]

And yet I get an error response that simply states

{"Message":"There was an error processing the  Request.","StackTrace":"","ExceptionType":""}

I have tried the method without sending data and also by sending simple non-array multi-parameter data and they both work just fine. It seems I'm missing a simple step or this JSON conversion isn't the right thing to do -- but clearly whatever it is, is evading me.

Any help appreciated,

related questions