I'm trying to parse JSON result retrieved from asp.net web method.
[WebMethod]
public static string readCheckOutResult()
{
string uKey = DateTime.Now.ToString("yyyyMMddHHmmss");
string customerNo = HttpContext.Current.Session["customerNo"].ToString();
Core core = new Core();
DataTable dt = core.checkoutCustomerCart(customerNo, uKey); //dt = checked out product
string JSONResult = DataTableToJSON.DataTableToJsonObj(dt);
return JSONResult;
}
Json Result received is somethink like below.
[{"CustomerNo":"33157880","ProductNo":"ALDC125DC-DIXON","CustomerProductNo":"","ProductDescription":"32MM AL D/CAST CAM TYPE DC DIX ",
"UOM":" ","Price":"11.93200","Qty":"1","SubTotal":"11.93200","uKey":"201511131242","ModifyDate":"13/11/2015 12:42:25 PM","ID":"190"}]
$.ajax({
type: "POST",
url: "checkout.aspx/readCheckOutResult",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function(codes) {
alert(codes.length);
var data = jQuery.parseJSON(codes.d);
for (var i = 0; i < data.d.length; i++) {
alert(data.d[i].CustomerNo);
}
alert(concatstring);
},
error: function() {
alert("Failed to Retrieve Data.");
}
});
I'm receiving the error codes.length is undefined. I also tried codes.d.length but no luck