Hi,
I have a JSON response that is formatted from my C# WebMethod using the JavascriptSerializer Class. I currently get the following JSON back from my query:
{"d":"[{\"Lat\":\"51.85036\",\"Long\":\"-8.48901\"},{\"Lat\":\"51.89857\",\"Long\":\"-8.47229\"}]"}
I'm having an issue with my code below that I'm hoping someone might be able to shed some light on. I can't seem to get at the information out of the values returned to me. Ideally I would like to be able to read in the Lat and Long values for each row returned to me.
Below is what I currently have:
$.ajax({
type: "POST",
url: "page.aspx/LoadWayPoints",
data: "{'args': '" + $('numJourneys').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != '[]') {
var lat = "";
var long = "";
$.each(msg.d, function () {
lat = this['Lat'];
long = this['Long'];
});
alert('lat =' + lat + ', long =' + long);
}
}
});
I think the issue is something to do with how the JSON is formatted but I might be incorrect. Any help would be great.
Thanks, Rich