JS dynamically reads the contents of XML files through Ajax

From , 5 Years ago, written in JavaScript, viewed 185 times.
URL https://pastebin.vip/view/6a711a11
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function loadXMLDoc(url)
  6. {
  7. var xmlhttp;
  8. if (window.XMLHttpRequest)
  9.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  10.   xmlhttp=new XMLHttpRequest();
  11.   }
  12. else
  13.   {// code for IE6, IE5
  14.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  15.   }
  16. xmlhttp.onreadystatechange=function()
  17.   {
  18.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  19.     {
  20.     document.getElementById('A1').innerHTML=xmlhttp.status;
  21.     document.getElementById('A2').innerHTML=xmlhttp.statusText;
  22.     document.getElementById('A3').innerHTML=xmlhttp.responseText;
  23.     }
  24.   }
  25. xmlhttp.open("GET",url,true);
  26. xmlhttp.send();
  27. }
  28. </script>
  29. </head>
  30. <body>
  31.  
  32. <h2>Retrieve data from XML file</h2>
  33. <p><b>Status:</b><span id="A1"></span></p>
  34. <p><b>Status text:</b><span id="A2"></span></p>
  35. <p><b>Response:</b><span id="A3"></span></p>
  36. <button onclick="loadXMLDoc('note.xml')">Get XML data</button>
  37.  
  38. </body>
  39. </html>
  40.  
  41.  
  42.  
  43. //javascript/8178

Reply to "JS dynamically reads the contents of XML files through Ajax"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website