user964918
user964918

Reputation: 29

Why AJAX does not work in Netscape Navigator?

I am using the following code in which the function is called onclick:

<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET","ajax_info.txt",true);
    xmlhttp.send();
}
</script>
</head>
<body>

<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>

</body>
</html>

It works in all the browser except netscape navigator

Upvotes: 2

Views: 701

Answers (1)

Spudley
Spudley

Reputation: 168655

It doesn't work in Netscape Navigator because this (ancient) browser doesn't support either the XMLHttpRequest object, nor the ActiveX alternative that works in older versions of IE.

The XMLHttpRequest object wasn't even invented when the last version of Navigator was released, and the ActiveX alternative only ever worked with IE.

If you're really desperate to make a modern Ajax site work on an ancient browser like this, you might be able to do something using the old 'hidden iframe' technique hack, but it'd be lot of work for virtually zero gain, and you'll still have loads of other issues to solve in order to support the browser.

Upvotes: 5

Related Questions