user2166417
user2166417

Reputation: 51

jQuery Ajax doesn't work on every version of Internet Explorer

The following piece of code works well on Internet Explorer 9 and 10 but gives no result in Internet Explorer 7 and 8.

$.ajax({
    url: url,
    cache: false,
    async: true,
    success: function(req, textStatus, obj) {
    },
    error: function(req, error, exc) {
        alert(req.responseText);
    } 
});

The result of the URL called by the Ajax request is:

<?xml version="1.0"?>
<BRILJANT>
    <VP>
        <NETTOVP>45,4545</NETTOVP>
        <NETTOVPINCL>55</NETTOVPINCL>
        <BRUTOVP>45,4545</BRUTOVP>
        <BRUTOVPINCL>54,9999</BRUTOVPINCL>
        <ORIVP>55,43</ORIVP>
        <ORIVPINCL>67,0703</ORIVPINCL>
        <KORTING1>0</KORTING1>
        <KORTING2>0</KORTING2>
        <SOORTPRIJS>P</SOORTPRIJS>
    </VP>
    <TEL>
        <VOORRAAD>0</VOORRAAD>
        <INBACKLEV>0</INBACKLEV>
        <INBACKKLA>6</INBACKKLA>
        <CONSIGN>0</CONSIGN>
        <MAGCTRL>0</MAGCTRL>
        <INPROD>0</INPROD>
        <OPAFLEVER>0</OPAFLEVER>
        <VOORRRES>0</VOORRRES>
        <VOORZPROD>0</VOORZPROD>
    </TEL>
</BRILJANT>

In Internet Explorer 7 and 8, the request object content is empty even if no error message is mentioned.

Any idea is well appreciated!

Upvotes: 3

Views: 183

Answers (2)

user2166417
user2166417

Reputation: 51

By adding this line of code for Internet Explorer version lower than 9, the DOM object was filled-in correctly!

$.ajax({
    url: url,
    cache: false,
    async: true,
    success: function(req, textStatus, obj) {
        >> if (ie < 9)
        >>    req = $.parseXML(obj.responseText);**
    },
    error: function(req, error, exc) {
        alert(req.responseText);
    } 
});

Upvotes: 1

nschonni
nschonni

Reputation: 4129

jQuery 2.0 dropped support for oldIE (<9), so if you are using the latest version there may be incompatibilities with IE7 & 8 so you should be using version 1.10 at most. If you are using a 1.X version, it is helpful to provide the version, as you may be using a version with a known bug.

Upvotes: 1

Related Questions