I'm very limited in javascript knowledge.. i'd appreciate any suggestions.. I've looked through previous JSON questions and answers, but didn't see anything that was similar to this.
I'm using jQuery. I have a JSON server response in the following format:
{
"aNumBids_1": "4",
"aHighBid_1": "100.00",
"aBidAmount_1": "110.00",
"aBidEnd_1": "09/27/2013 17:00",
"aNumBids_2": "42",
"aHighBid_2": "1,210.00",
"aBidAmount_2": "1,260.00",
"aBidEnd_2": "09/27/2013 17:01",
"aNumBids_3": "12",
"aHighBid_3": "1,100.00",
"aBidAmount_3": "1,150.00",
"aBidEnd_3": "09/27/2013 17:02",
"aNumBids_4": "26",
"aHighBid_4": "1,460.00",
"aBidAmount_4": "1,510.00",
"aBidEnd_4": "09/27/2013 17:03",
"aNumBids_5": "32",
"aHighBid_5": "1,210.00",
"aBidAmount_5": "1,260.00",
"aBidEnd_5": "09/27/2013 17:04"
}
the first element of each pair is the element name on the page ( name='aBidAmount_5'
). The second element of each pair is the content to be placed into that element.
How do i go about looping through this json response ?
I've gotten this far:
AJAX.getPrice = function(){
var request = $.ajax({
url: serverScript,
data: JSON.stringify(aItems) ,
dataType: "json"
});
request.done(function() {
// update the element value
/* i'm lost here */
});
request.fail(function(jqXHR, textStatus) {
// If console is available output the error to console log
if (typeof console == "object") {
console.log( "Request failed: " + textStatus +data );
}
});
}