Skip to content
Rayhan Uddin edited this page Jun 2, 2017 · 2 revisions
        <script type="text/javascript">
              function createXHR()
             {
                var xhr;
              if (window.ActiveXObject)
                    {
                        try
                           {
                              xhr = new ActiveXObject("Microsoft.XMLHTTP");
                           }
                       catch(e)
                              {
                               alert(e.message);
                               xhr = null;
                              } 
                     }
                else
                    {
                     xhr = new XMLHttpRequest();
                    }
                   return xhr;
                 }


          function loadXMLDoc() {
          var xmlhttp = createXHR();

          xmlhttp.onreadystatechange = function() {
         if(xmlhttp.readyState == XMLHttpRequest.DONE ) {
         if (xmlhttp.status == 200) {
         document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
          }
           else if (xmlhttp.status == 400) {
           alert('There was an error 400');
         }
       else {
           alert('something else other than 200 was returned');
           }
         }
       };

     xmlhttp.open("GET", "ajax_info.txt", true);
     xmlhttp.send();
     }
    </script>
Clone this wiki locally