Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.99 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. IE alternative to window.stop() (cancel all pending requests)
  2. (function ($) {
  3.     var xhr = null,
  4.         originalAjax = $.ajax,
  5.         updatedAjax = function (url, options) {
  6.             xhr = originalAjax(url, options);
  7.         };
  8.     $.ajax = updatedAjax;
  9. })(jQuery);
  10.        
  11. <html>
  12. <head>
  13. <script type="text/javascript">
  14. function loadXMLDoc()
  15. {
  16. if (window.XMLHttpRequest)
  17.   {// code for IE7+, Firefox, Chrome, Opera, Safari
  18.   xmlhttp=new XMLHttpRequest();
  19.   }
  20. else
  21.   {// code for IE6, IE5
  22.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  23.   }
  24. xmlhttp.onreadystatechange=function()
  25.   {
  26.   if (xmlhttp.readyState==2){ xmlhttp.abort();}
  27.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  28.     {
  29.     document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  30.     }
  31.   }
  32. xmlhttp.open("GET","xmlhttp_info.txt",true);
  33. xmlhttp.send();
  34. }
  35. </script>
  36. </head>
  37. <body>
  38.  
  39. <h2>Using the XMLHttpRequest object</h2>
  40. <div id="myDiv"></div>
  41. <button type="button" onclick="loadXMLDoc()">Change Content</button>
  42.  
  43. </body>
  44. </html>