Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,46 @@
1
+function ajaxObject(url, callbackFunction) {
2
+  var that=this;      
3
+  this.updating = false;
4
+  this.abort = function() {
5
+    if (that.updating) {
6
+      that.updating=false;
7
+      that.AJAX.abort();
8
+      that.AJAX=null;
9
+    }
10
+  }
11
+  this.update = function(passData,postMethod) { 
12
+    if (that.updating) { return false; }
13
+    that.AJAX = null;                          
14
+    if (window.XMLHttpRequest) {              
15
+      that.AJAX=new XMLHttpRequest();              
16
+    } else {                                  
17
+      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
18
+    }                                             
19
+    if (that.AJAX==null) {                             
20
+      return false;                               
21
+    } else {
22
+      that.AJAX.onreadystatechange = function() {  
23
+        if (that.AJAX.readyState==4) {             
24
+          that.updating=false;                
25
+          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
26
+          that.AJAX=null;                                         
27
+        }                                                      
28
+      }                                                        
29
+      that.updating = new Date();                              
30
+      if (/post/i.test(postMethod)) {
31
+        var uri=urlCall+'?'+that.updating.getTime();
32
+        that.AJAX.open("POST", uri, true);
33
+        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
34
+        that.AJAX.setRequestHeader("Content-Length", passData.length);
35
+        that.AJAX.send(passData);
36
+      } else {
37
+        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
38
+        that.AJAX.open("GET", uri, true);                             
39
+        that.AJAX.send(null);                                         
40
+      }              
41
+      return true;                                             
42
+    }                                                                           
43
+  }
44
+  var urlCall = url;        
45
+  this.callback = callbackFunction || function () { };
46
+}
0 47
\ No newline at end of file