Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Ajax = new Object();
- Ajax.getXHR = function() {
- var http;
- try {
- http = new XMLHttpRequest;
- Ajax.getXHR = function() {
- return new XMLHttpRequest;
- };
- }
- catch(e) {
- var msxml = [
- 'MSXML2.XMLHTTP.3.0',
- 'MSXML2.XMLHTTP',
- 'Microsoft.XMLHTTP'
- ];
- for (var i=0, len = msxml.length; i < len; ++i) {
- try {
- http = new ActiveXObject(msxml[i]);
- Ajax.getXHR = function() {
- return new ActiveXObject(msxml[i]);
- };
- break;
- }
- catch(e) {}
- }
- }
- return http;
- };
- Ajax.handleReadyState = function(o, callback) {
- if (o && o.readyState == 4 && o.status == 200) {
- if (callback) {
- callback(o);
- }
- }
- };
- Ajax.call = function(method, uri, callback, postData) {
- var http = Ajax.getXHR();
- http.onreadystatechange = function(){Ajax.handleReadyState(http, callback)};
- http.open(method, uri, true);
- //if(method=='POST'){http.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=utf-8');}
- http.send(postData || null);
- return http;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement