I have a PHP file that scrapes an external URL for certain classes, then puts them into an array. I have then encoded the array using json_encode(). The array is in the order it must be iterated, but for some reason the JSON doesn't iterate in the correct order. It's in descending order, instead of ascending order.
Here is an example of the JSON returned:
[{
"id":1,
"info":
{
"title":"Design Prepaid cards with HD quality ",
"titleurl":"http:\/\/www.peopleperhour.com\/job\/design-prepaid-ards-with-hd-quality-380258",
"price":"\u00a3 400 ",
"urgent":"Urgent",
"jobID":"380258"
}
},
{
"id":2,
"info":
{
"title":"Charted accontant",
"titleurl":"http:\/\/www.peopleperhour.com\/job\/charted-accontant-380251",
"price":"\u00a3 60 ",
"urgent":"Urgent",
"jobID":"380251"
}
}]
This is how I am currently displaying the JSON:
var jsonResults = JSON.parse(data);
var count = (jsonResults.length);
// Iterate Through Results
$.each(jsonResults, function(key, value)
{
// Display Data
$('#resultsPanel').fadeIn('slow');
$('#resultsPanel').prepend(
'<div class="item" id="'+ value.info.jobID +'">'+
'<div class="title"><a href="'+ value.info.titleurl+'" target="_blank">'+ value.info.title +'</a></div>'+
'<div class="price">'+ value.info.price +'</div>'+
'</div>'
);
});
Is it possible to order the JSON?