getXDomainRequest not working on IE but works anywhere else

169 views Asked by At

I have this function which returns some XML datas from a foreign website :

function sendData()
{
        var dev_statut = jQuery("select[name='statut']").val();
        var dev_fdpaysid = jQuery("select[name='pays']").val();
        var dev_fddeffet = jQuery("input[name='date_effet']").val();
        var dev_fdnbadu = jQuery('select[name="nb_adultes"]').val();
        var dev_fdnbenf = jQuery('select[name="nb_enfants"]').val();

        var date_naiss_a_val = jQuery("input[name^=date_naissance_a]").map(function() {        
        var dev_date_naiss_a = 'dev_fadnaiss_';
        return dev_date_naiss_a + this.id + '=' + this.value; 
        }).get().join('&');

         var date_naiss_e_val = jQuery("input[name^=date_naissance_e]").map(function() { 
         var dev_date_naiss_e = 'dev_fadnaiss_';
         return dev_date_naiss_e + this.id + '=' + this.value; 
         }).get().join('&');

        var xdr = getXDomainRequest();
        xdr.onload = function() 
        {
                alert(xdr.responseXML);

                var xml = xdr.responseXML; 
                var prod = xml.documentElement.getElementsByTagName("produit");

                var proddata = [];

                proddata.push('<ul>');

                var len = prod.length;
                for (var i = 0; i < len; i++) {

                var nomprod = xml.getElementsByTagName('nomprod')[i].firstChild.nodeValue;
                var url = xml.getElementsByTagName('url')[i].firstChild.nodeValue;
                var desc = xml.getElementsByTagName('desc')[i].firstChild.nodeValue;
                var texte = xml.getElementsByTagName('texte')[i].firstChild.nodeValue;

                proddata.push("<li><div class='resultat_produit'>" + "<h1>" + nomprod + "</h1>" + "<p class='from_devis_desc'>" + desc + "</p>" + "<p class='form_devis_texte'>" + texte + "</p>" + "<a href='" + url + "'class='btn_url'>Faire un devis</a>" + "</div></li>");
                }

                proddata.push('</ul>');
                jQuery('#mydiv2').append(proddata.join("\n"));

                jQuery('.resultat_produit a').click(function(e)
                {
                        e.preventDefault();

                        var href = jQuery(this).attr('href');

                        jQuery('#myDiv').empty();
                        jQuery('#myDiv').append('<iframe src="'+ href +'" scrolling="auto" width="960" height="100%"></iframe>');
                });
        }
        xdr.open("GET", "http://www.MYURL.fr/page.php?dev_statut="+ dev_statut +"&dev_fdpaysid="+ dev_fdpaysid +"&dev_fddeffet="+ dev_fddeffet +"&dev_fdnbadu="+ dev_fdnbadu +"&dev_fdnbenf="+ dev_fdnbenf +"&"+ date_naiss_a_val +"&"+ date_naiss_e_val +"");
        xdr.send();
} 

It works fine on any major browsers (Chrome, FF, etc) but not on ... IE ! I've opened the console and it says : "DocumentElement is undefined ..."

I'm tired and can't fix that, any help will be very very appreciated !!

0

There are 0 answers