views:

82

answers:

2

Dear All, I have one js file with a ajax call which is working fine in IE6, but not in IE7 or FF. Can somebody help?

window.onload = function() {
    var xmlhttp;
    var url = "myurl";
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
    debugger;
    alert("Hello");
        // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else {
        alert("Your browser does not support XMLHTTP!");
    }
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            alert(xmlhttp.responseText);
        }
    }
}

In IE7 I am getting access denied error. Please help.

EDIT: I am now trying it using jQuery, Code:

$(function() {       
        $.ajax(
                    {
                        type: "GET",
                        url: "myurl",
                        datatype: "html",
                        success: function(xhtml) {
                          $("#con").html(xhtml);
                        },
                        error: function() {
                            displayMessage(......);
                        }
                    });
    });

Still its working in IE6 but not in Others.If its a cross domain issue, then how to solve this?

A: 

It might be some security issues. See if it works by adding all url's you use here to the trusted sites list.

awe
A: 

IE6 has known bugs/issues when it comes to Javascript and cross-domain policy. This is why (amongst other reasons) that IE6 is no longer being supported in terms of cross-browser compatibility by many large organizations (why encourage something that has such a vulnerability?)

My guess, then, is that your var url = "myurl" is pointing to something on another domain or subdomain. But we need more details to be sure.

Anthony
Which cross-domain issues are there in IE6?
kangax
Check out the following: http://www.sans.org/top20/#c1 I know somewhere I found a really specific one. I'll see if I can dig it up.
Anthony