Guest User

Untitled

a guest
Jun 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. if(typeof asyncRequest == 'undefined') {
  2.  
  3. asyncRequest = {};
  4. }
  5.  
  6. asyncRequest.REQUEST = function() {
  7.  
  8. function handleReadyState(o,callback) {
  9.  
  10. o.onreadystatechange = function() {
  11.  
  12. if(o.readyState == 4) {
  13.  
  14. if(o.status == 200) {
  15.  
  16. callback(o.responseXML);
  17.  
  18. }
  19. }
  20. }
  21. }
  22.  
  23. var XHR = function() {
  24.  
  25. var http;
  26.  
  27. try {
  28.  
  29. http = new XMLHttpRequest();
  30.  
  31. XHR = function(){return new XMLHttpRequest();}
  32.  
  33. }catch(e) {
  34.  
  35. try {
  36.  
  37. http = new ActiveXObject("Microsoft.XMLHTTP");
  38.  
  39. XHR = function(){return new ActiveXObject("Microsoft.XMLHTTP");}
  40.  
  41. }catch(e){}
  42. }
  43.  
  44. return XHR();
  45. }
  46.  
  47. return function(method,url,callback,postData) {
  48.  
  49. var http = XHR();
  50.  
  51. http.open(method,url,true);
  52.  
  53. if(postData) {
  54.  
  55. //Send the proper header information along with the request
  56. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  57.  
  58. http.setRequestHeader("Content-length", postData.length);
  59.  
  60. http.setRequestHeader("Connection", "close");
  61. }
  62.  
  63. handleReadyState(http,callback);
  64.  
  65. http.send(postData || null);
  66.  
  67. return http;
  68. }
  69. }();
Add Comment
Please, Sign In to add comment