I have the following code:
// Setup a content array for the tooltips
var Data = [];
var search = $("input#field_search").val();
var combo = $("select#search_option").val();
var jsonUrl = "ajax.php?module=formation&action=get_participant_list_json&filter_by=" + combo + "&search=" + search;
$.getJSON(jsonUrl, function(data) {
var items = [];
alert(data.join(" || " )); //WHAT TO SHOW YOU HERE
$.each(data, function(key, val) {
//alert(val);
items.push(val.replace(/@/gi, "#"));
});
//console.log(items);
//alert(items.join(" || " ));
$(".tips").each(function(i) {
$(this).simpletip({ content: items[i] });
});
});
If I access
ajax.php?module=formation&action=get_participant_list_json
or
ajax.php?module=formation&action=get_participant_list_json&filter_by=&search=
directly with IE7, I get the good response data in the following order:
["0Bequart Claire","1AZZI Sarah"]
But if I alert(data.join(" || " )); I got reversed
0AZZI Sarah || 1Bequart Claire
Do you know where my mistake is? Why is the response list in reverse order?
Thanks for your help
I cannot completely follow your code so I apologise if I have misunderstood, but .push looks like an operation intended to implement a LIFO stack. If you want to unload (list) the array in the same order that you loaded it, you should load it with an append operation and unload it with an iterator.