I'm calling a web service and returning the following data in JSON format:
[{"OrderNumber":"12345","CustomerId":"555"}]
In my web service success method, I'm trying to parse both:
$.ajax({
type: "POST",
url: "MyService.asmx/ServiceName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var data = msg.d;
var rtn = "";
$.each(data, function(list) {
rtn = rtn + this.OrderNumber + ", " + this.CustomerId + "<br/>";
});
rtn = rtn + "<br/>" + data;
$("#test").html(rtn);
}
});
but I'm getting a bunch of "undefined, undefined" rows followed by the correct JSON string. Any idea why? I've tried using the eval()
method but that didn't help as I got some error message talking about ']' being expected.