code in xmlhttp.readyState==4 doen't get executed

Posted by shazia on Stack Overflow See other posts from Stack Overflow or by shazia
Published on 2010-12-30T06:31:44Z Indexed on 2010/12/30 6:53 UTC
Read the original article Hit count: 189

Filed under:
|
|
function download() {
    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() 
    {   //alert(xmlhttp.readyState);
        if(xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            alert (xmlhttp.responseText);
        }   
    }

    xmlhttp.open("GET","import.php?file="+document.getElementById('uploaded_file').value,false);
    xmlhttp.send(); 

  //  location.reload(true);
}

if I put alert and monitor xmlhttp.readyState then it shows me that its status does turn 4 and it does go in the if statement, if I don't monitor it with alert then it doesn't go in the if statement but I know import.php is working because I can see the changes in the database. I don't know whats going on...can anyone help.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript