I have a web service that returns this string via the jQuery $.ajax() call in the success callback:
[{"WaitlistID":1,"RID":45034,"CustomerID":2765957,
"IsAdmin":false,"TruckSize":1,"Points":1},
{"WaitlistID":2,"RID":45034,"CustomerID":2765957,
"IsAdmin":false,"TruckSize":1,"Points":1}]
Unfortunately if I call $.each() on that value in the success callback it iterates over every letter in it, and doesn't treat it as a two element array, which is what I'd like. I've tried the makeArray() function but haven't had any luck, how can I convert that string into a JSON object array?
edit:
In response to the comments (thanks, everyone) I already do set the dataType to 'json', which is odd. Here's the code in question.
jQuery.ajax({
type: "POST",
url: pagePath + "/" + fn,
contentType: "application/json; charset=utf-8",
data: paramList,
dataType: "json",
success: successFn,
error: errorFn
});
..so I'm not sure why it didn't work originally, but the parseJSON() bit did the trick. Appreciate everyone's help.
dataType:json. It will parse the json for you and give you an object as the parameter to yoursuccess()function.