Advertisement
Guest User

xhr

a guest
Nov 10th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. if (window.XMLHttpRequest)
  2. {// code for IE7+, Firefox, Chrome, Opera, Safari
  3. xhr=new XMLHttpRequest();
  4. }
  5. else
  6. {// code for IE6, IE5
  7. xhr=new ActiveXObject("Microsoft.XMLHTTP");
  8. }
  9.  
  10. $(function() {
  11. var url = "http://www.google.com";
  12. $.ajax(url,
  13. {
  14. error:function (xhr, ajaxOptions, thrownError){
  15. alert(xhr.status);
  16. switch (xhr.status) {
  17. case 404:
  18. // Desired Action.
  19. }
  20. }
  21.  
  22. complete: function(xhr, statusText){
  23. alert(xhr.status);
  24. }
  25. }
  26. });
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement