Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 为什么$.getJSON会反转响应列表?_Ajax_Jquery - Fatal编程技术网

Ajax 为什么$.getJSON会反转响应列表?

Ajax 为什么$.getJSON会反转响应列表?,ajax,jquery,Ajax,Jquery,我有以下代码: // 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=" +

我有以下代码:

// 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] });
    });
});
如果我访问

ajax.php?module=formation&action=get\u participant\u list\u json

ajax.php?module=formation&action=get\u participant\u list\u json&filter\u by=&search=

直接使用IE7,我可以按照以下顺序获得良好的响应数据:

["0Bequart Claire","1AZZI Sarah"]
但是如果我
alert(data.join(“| |”)我倒过来了

  0AZZI Sarah || 1Bequart Claire
你知道我的错在哪里吗?为什么响应列表的顺序相反


感谢您的帮助

我无法完全理解您的代码,因此如果我误解了,我很抱歉。push看起来像是一个旨在实现后进先出堆栈的操作。如果要按加载数组的相同顺序卸载(列出)数组,则应使用追加操作加载数组,然后使用迭代器卸载数组。

您应该访问完整的URL,而该URL看起来就像它的一半。为什么?但是如果ajax.php?module=formation&action=get\u participant\u list\u json&filter\u by=&search=alert(data.join(“| |”)的话,我仍然得到了相同的结果;我还没有做任何推送,只是保持警惕