0

This is first time I am attempting to send data to server using Ajax. I followed lot of answers from here but I won't just stop getting the error : "Message":"Invalid web service call, missing value for parameter: \u0027Products\u0027."

I followed this and this but still the same. Can someone please tell me where I am going wrong.

        var products =  [ { ProductId : 1, ProductName : "Mercedes", Category : "Cars", Price : 25000 }, { ProductId : 2, ProductName : "Otobi", Category : "Furniture", Price : 20000 } ];

    function GetProductId() {
        $.ajax({
            type: "POST",
            url: "Default.aspx/GenerateQrCode",
            data: { "Products" : products.toString()  },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(xhr.responseText);
                alert(thrownError);
            },
            success: function (msg) {
                alert('Success');
            }
        });
    }


[WebMethod]
    public static void GenerateQrCode(object Products)
    {
        //Cannot get to here
    }
2
  • try : data: { Products : products }, jQuery will parse the object for you- Commented May 25, 2013 at 16:47
  • This is not working. Same error. Commented May 25, 2013 at 17:22

2 Answers 2

3

Try this -

data : "{'Products':" + JSON.stringify(products) + "}"
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Your solution is working but it is only working on Chrome but not in IE10. Do you have any idea why?
0

Try this -

data : {Products: JSON.stringify(products)}

or

data : {Products: products}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.