I just realized I am having a malfunction in my overall web app and it's coming down to a for loop that is reordering my object/array.
I am retrieving an associative array (object) via AJAX. I can check it's structure upon return and it is correct. For example:
48 => Value1
50 => Value2
49 => Value3
51 => Value4
But, when I loop through it, the for loop reorders the object. This is because the assoc keys are numeric. They represent numeric IDs froma database. I didn't know javascript would choke on them and try to turn them into basic array keys in numeric order. So, it spits out as:
48 => Value1
49 => Value3
50 => Value2
51 => Value4
How can I loop through the object in the order I build it in? Do I have to build the object with strings as keys? Like "ID22" replacing 22. Or is there some way to force javascript to loop in a specific order?
Thanks! Matt