Advertisement
Guest User

Untitled

a guest
Aug 29th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.75 KB | None | 0 0
  1. <script>
  2.             var xmlhttp;
  3.  
  4.             window.onload = function() {
  5.                 document.addEventListener("deviceready", init, false);
  6.             }
  7.            
  8.             function init() {
  9.                 var url = "http://foobar.com/index.php"
  10.                 xmlhttp = new XMLHttpRequest();
  11.                 xmlhttp.onreadystatechange = processResponse;
  12.                 xmlhttp.open("GET", url, true);
  13.                 xmlhttp.send();
  14.             }
  15.  
  16.             function processResponse() {
  17.                 console.log(xmlhttp.readyState + " " + xmlhttp.status);
  18.                 if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  19.                    
  20.                     document.getElementById('testdiv').innerHTML = xmlhttp.responseText;
  21.                 } else {
  22.                     document.getElementById('testdiv').innerHTML = "<strong>Waiting...</strong>";
  23.                 }
  24.             }
  25.  
  26.         </script>
  27.  
  28.         <body>
  29.             <div id="testdiv"></div>
  30.         </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement