jQuery错误访问数据IE11

时间:2016-05-09 16:57:39

标签: javascript jquery ajax xml

我有一小段代码通过AJAX调用调用数据库,并返回一个由jQuery循环的XML字符串。

这在Firefox中运行良好,但在IE11中无效。

我在JSFiddle中重复了这个问题,但是硬编码了从AJAX调用返回的XML字符串。

// Define our vars
var fieldIDsArray = Array(),
    data = "<root><results><dashboardID>77</dashboardID><dashboardOwner>Q123</dashboardOwner><logic><data><fieldID>13</fieldID><fields><field><fieldTitle>Project Created in Last x Days</fieldTitle><queryField>daysSinceCreation</queryField><allowMultiple>0</allowMultiple><isPeople>0</isPeople><isDate>0</isDate><isSelect>0</isSelect><isInput>1</isInput><placeholder>Project Created in Last x Days</placeholder><span>4</span><values><data><value>30</value></data></values></field></fields></data><data><fieldID>25</fieldID><fields><field><fieldTitle>Project Impacted Ops Locations</fieldTitle><queryField>impactedOpsLocationsXML</queryField><allowMultiple>1</allowMultiple><isPeople>0</isPeople><isDate>0</isDate><isSelect>1</isSelect><isInput>0</isInput><placeholder>Select one or more Impacted Ops Locations</placeholder><span>8</span><selectOptions>initiativeLocations</selectOptions><values><data><value>Berlin</value></data></values></field></fields></data></logic><sorting><logic><dashboardID>77</dashboardID><fieldID>8</fieldID><sort>ASC</sort><order>1</order><fieldName>Project Creation Date</fieldName></logic></sorting></results></root>",
    output = '';

// First, we need to loop over all of the fields and load them onto the page
$(data)
    .find('logic>data')
    .each(function () {

        // Define our parent data
        parent = $(this);

        // Add our fields to an array
        fieldIDsArray.push($(parent)
            .find('fieldID')
            .text());

    });

// Pass the array of field ID's to our function to re-create the inputs the user selected
selectLogic(fieldIDsArray, data);

// Function to receive data
function selectLogic(array, data) {
    // Loop over the array
    $(array)
        .each(function () {
            output += this + ' <br />';
        });

    // Append the results
    $('[name=results]')
        .empty()
        .append(output);
}

小提琴:https://jsfiddle.net/3qc01bpb/

知道为什么这段代码在IE11中不起作用但在firefox中运行正常吗?

0 个答案:

没有答案