locked
Ajax does not work for Firefor, Solution Here RRS feed

  • Question

  • User-843210691 posted

     Generally simple ajax code doesnot work for Firefox and lot of questions are floating over internet. But here is the solution.

    <script type="text/javascript">
    var request; function getName(){
    var roll = document.getElementById("roll").value;
    var url = "http://localhost:8080/blog_demo/StudentInfo?roll="+roll;
    
    if(window.ActiveXObject){
    request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest){
    request = new XMLHttpRequest();
    }
    
    request.onreadystatechange = showResult;
    request.open("POST",url,true);
    request.send(null);
    }
    function showResult(){
    if(request.readyState == 4){
    if ( request.status == 200 ) {
    var response = request.responseXML;
    var students = response.getElementsByTagName("Student");
    var student = students[0];
    
    document.getElementById("NamelH1").innerHTML = student.getElementsByTagName("Name")[0].childNodes[0].data;
    document.getElementById("HostelH1").innerHTML = student.getElementsByTagName("Hostel")[0].childNodes[0].data;
    document.getElementById("ContactH1").innerHTML = student.getElementsByTagName("Contact")[0].childNodes[0].data;
    
    
    }
    }
    }
    </script>
    


     

    http://binodsuman.blogspot.com/2009/06/ajax-program-for-firefox-ajax-does-not.html

    Thanks,

    Binod Suman

    http://binodsuman.blogspot.com

     

     

     

    Saturday, June 27, 2009 12:08 PM

All replies