1 var AJAX = { 2 get: function(url, data, callback) { 3 var query = ""; 4 for (var i in data) { 5 query += i + "=" + data + "&"; 6 } 7 query = query.slice(0, -1); 8 var xhr = null; 9 if (window.XMLHttpRequest) { 10 xhr = window.XMLHttpRequest(); 11 } else if(window.ActiveXObject) { 12 xhr = window.ActiveXObject ( "Micorsoft.XMLHTTP" ); 13 } the else { 14 Alert ( "Your browser does not support AXAJ, please upgrade" ) 15 } 16 xhr.onreadystatechange = function () { . 17 IF (xhr.readyState ===. 4 ) { 18 is var obj = the JSON.parse (xhr.responseText); . 19 the callback (obj); 20 is } 21 is } 22 is "?" xhr.open ( "GET", URL + Query +, to true ); 23 xhr.send(); 24 }, 25 post:function() { 26 var query = ""; 27 for (var i in data) { 28 query += i + "=" + data + "&"; 29 } 30 query = query.slice(0, -1); 31 var xhr = null; 32 if (window.XMLHttpRequest) { 33 xhr = window.XMLHttpRequest(); 34 } else if(window.ActiveXObject) { 35 XHR = window.ActiveXObject ( "Micorsoft.XMLHTTP" ); 36 } the else { 37 [ Alert ( "Your browser does not support AXAJ, upgrade" ) 38 is } 39 xhr.onreadystatechange = function () { 40 IF (xhr.readyState ===. 4 ) { 41 is var obj = the JSON.parse (xhr.responseText); 42 is the callback (obj); 43 is } 44 is } 45 xhr.open ( "POST", URL, to true ); 46 xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded;charset=utf-8") 47 xhr.send(query); 48 } 49 }