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);
2

1 Answer 1

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"},
    ...
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.