clintnash
asked on
Accessing data in JSON response.d
I think after 50 rounds back to google and an unending set of error responses I need help. I am successfully generating a JSON response (I can see it in Firebug) but cant access the underlying data. The JSON response is
My javascript to make the request is
I just need to be able to get access to the individual items in the response, for example
var tTeams = response.d("TargetTeams"); (which doesn't work)
Any advice or input would be greatly appreciated.
{"d":[{"__type":"CurrentTeams","CurrentTeams":756,"TargetTeams":688,"RangeMax":1200,"TickInterval":200
,"Tick1":300,"Tick2":600,"Tick3":900}]}
My javascript to make the request is
$(document).ready(function () {
$(function () {
$.ajax({
type: "POST",
url: "../services/seasons_svc.aspx/LoadCurrentSeasonsWithTarget",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("d");
alert($(xmlDoc));
I just need to be able to get access to the individual items in the response, for example
var tTeams = response.d("TargetTeams");
Any advice or input would be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, in my attempts I missed the index of d. This nailed it.
You are welcome.
Open in new window