I have a script which returns a data array in JSON as per below.
[
{"ItemID":"10319","ItemCode":"ITEM-010318","Qty":"1","custRef":"12 - Mitsubishi Fighter FK61F"},
{"ItemID":"10933","ItemCode":"ITEM-010932","Qty":"1","custRef":"12 - Mitsubishi Fighter FK61F"},{"ItemID":"10537","ItemCode":"ITEM-010536","Qty":"1","custRef":"12 - Mitsubishi Fighter FK61F"},
{"ItemID":"14863","ItemCode":"ITEM-014862","Qty":"1","custRef":"12 - Mitsubishi Fighter FK61F"},
{"ItemID":"14864","ItemCode":"ITEM-014863","Qty":"1","custRef":"12 - Mitsubishi Fighter FK61F"}
]
This data is stored in a variable called cartData
I then push the data to my WebMethod via AJAX, as follows
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "OrderFormServices.asmx/AddItemsToCart",
data: JSON.stringify(cartData),
dataType: "json"
});
My web method looks like this
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void AddItemsToCart(string [] itemID, string [] itemCode, string [] Qty, string [] custRef)
However when I try and POST the data, I get an error on the console which I can't make head or tail of! Can anyone shed some light on it?
Type 'System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089],
[System.Object, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'
is not supported for deserialization of an array.