2

Here is my JSON from server

"bids":{"51200512":{"bidAmt":"Rs.63,736,494.00","date":"2014 12 12 09:49:59 AM","bidder":"Amit"},

"69120512":{"bidAmt":"Rs.734,294.00","date":"2014 12 12 09:51:29 AM","bidder":"Tata India Pvt Ltd"},

"66560256":{"bidAmt":"Rs.87,265.00","date":"2014 12 12 09:52:31 AM","bidder":"Tata Telecommunication servoices <i>asas</i> Telec"},

"69120768":{"bidAmt":"Rs.63,737.00","date":"2014 12 12 09:52:05 AM","bidder":"Tata India Pvt Ltd"},

"69120256":{"bidAmt":"Rs.63,736.00","date":"2014 12 12 09:50:50 AM","bidder":"Tata India Pvt Ltd"}}}

In fire fox its shows the correct order i.e.

Rs.63,736,494.00
Rs.734,294.00
Rs.87,265.00
Rs.63,737.00
Rs.63,736.00

but in chrome:

Rs.63,736,494.00
Rs.734,294.00
Rs.63,736.00
Rs.734,294.00
Rs.63,737.00

Here is how i am parsing my JSON

 $.each(bids,function(k,v){
       _tbl+="<tr bd='y'><td><a href=\""+_this.options.context+"/profile/"+k+"\">"+v.bidder+"</a><br/><small><span class='timeago' title='"+v.date+"'>"+v.date+"</span><small></td><td>"+v.bidAmt+"</td></tr>";
 });}

$("#showBidModel table").append(_tbl);
Manish Kumar
  • 10,214
  • 25
  • 77
  • 147

1 Answers1

7

Javascript does not guarantee the order of objects. See Does JavaScript Guarantee Object Property Order?.

Chrome happens to iterate through them with the numeric keys first in sorted order. If you need explicit ordering, use an array.

"bids": [
    {"id": "69120512", "bidAmt":"Rs.734,294.00","date":"2014 12 12 09:51:29 AM","bidder":"Tata India Pvt Ltd"},
    {"id": "66560256", "bidAmt":"Rs.87,265.00","date":"2014 12 12 09:52:31 AM","bidder":"Tata Telecommunication servoices &lt;i&gt;asas&lt;/i&gt; Telec"},
    ...
]
Community
  • 1
  • 1
Justin Howard
  • 5,504
  • 1
  • 21
  • 48