0

I have a small piece of code that calls the database via an AJAX call and returns an XML string that is looped over by jQuery.

This works fine in firefox but will not work in IE11.

I duplicated the issue in JSFiddle but hardcoding the XML string that would have been returned from the AJAX call.

// 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);
}

Fiddle: https://jsfiddle.net/3qc01bpb/

Any idea why this piece of code would not work in IE11 but run fine in firefox?

Marcus
  • 822
  • 1
  • 8
  • 27
SBB
  • 8,560
  • 30
  • 108
  • 223
  • There seems to be an "access denied" error in IE 11 while accessing jquery 1.9.1. Check this : http://stackoverflow.com/questions/20360719/ie-throwing-access-denied-error – DinoMyte May 09 '16 at 17:05
  • I believe you are running into [this](http://stackoverflow.com/a/17371187). Did you use the IE console to look for errors? – TheNorthWes May 09 '16 at 17:05
  • I did try and use the console but nothing was being thrown. When I had my AJAX call, I had the `dataType: xml` and I got permission denied on trying to see its contents. I had to changed it to `dataType: text` in order to be able to see what was being passed. My current jQuery on this legacy site is 1.9.1, not the mentioned 1.10.x like in the examples. I suppose I can try upgrading it to see if thats the cause. – SBB May 09 '16 at 17:11
  • It looks like the issue was due to IE 11 not liking that I didn't have parent define before calling it : `var parent;`. I know I have never had an issue like that before in older IE versions, is this something new? While I know its best practice to do so anyway, I never did it when using a variable within a loop and got away with it until now. – SBB May 09 '16 at 17:47

0 Answers0