Hi,
I have developed small AJAX application, that gets the data from server and prints in the div element.. the AJAX request takes some time.. till the response returns I want to display the text ""Content is Loading, please wait...." in the <div> element...
The code is shown below.. This works perfectly fine with FireFox but in IE(6 and 7) I won;t get the "Content is Loading, please wait...." text I get the Ajax response from the server.

I tried having different <div> element but no help... :(
Any help will be greatly appreciated..

<script type="text/javascript">

var xmlhttp;
function loadXMLDoc(thisform){  

   document.getElementById('out').innerHTML="";
   document.getElementById('out').innerHTML="Content is Loading, please wait....";

   url  = "someurl";        
   xmlhttp=null;

    if (window.ActiveXObject)
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }   
    else
    {
        if (window.XMLHttpRequest)
        {// code for , Firefox, Opera, etc.
            xmlhttp=new XMLHttpRequest();
        }
    }
    if (xmlhttp!=null)
    {
         xmlhttp.open("GET",url,false);       
         xmlhttp.send(null);     
            // Replacing the <div> value with Ajax output.
        document.getElementById('out').innerHTML=xmlhttp.responseText;      
      }
    }
    else
    {
      alert("Your browser does not support Ajax.");
    }
}

</script>
</head>

<body>

<form name=one>
Click</font><input type="text"  width="100" size=50 name=path>
<input type=button value=SUBMIT onClick="loadXMLDoc(document.one)" >
</form>

<div name=out id=out></div>
</body>
</html>

CrossBrowser Issue!
You may try this 1 instead!

if ( document.all ) { 
document.all.out.innerHTML = "Content is Loading, please wait...."; }
if ( document.getElementById && !document.all ) { 
document.getElementById('out').innerHTML="Content is Loading, please wait...."; }

Don't use document.all.

Also, the markup in the original post is thoroughly broken with the tag attribute values not quoted. Make sure you validate your markup using W3C validator to avoid browsers to correct your errors in their own way which may differ across browsers.

Thanks for reply..

I have tried document.all and checked all markup tags , every thing seems fine..

One more thing I noticed in IE is, if I put some alert() after first inner HTML
I would able to see the text "Content is Loading, please wait....". before alert popup,


.....
document.getElementById('out').innerHTML="Content is Loading, please wait....";
alert('Here I am');
....
....
document.getElementById('out').innerHTML=xmlhttp.responseText;

In ur code in second if-block there is extra '}' present.

You waste ur time doing such silly mistakes.
Copy & Paste not always work!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.