代码出处:https://github.com/jaywcjlove/FED 1. [代码] ajax调用方法 function ajax(url,callback){ var xhr; try {xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e){ try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }catch (e2)
1. [代码]ajax调用方法
function ajax(url,callback){ var xhr; try {xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e){ try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); }catch (e2){ try { xhr = new XMLHttpRequest(); } catch (e3) { xhr = false; } } } xhr.onreadystatechange = function(){ if(xhr.readyState == 4 && xhr.status == 200){ callback&&(callback(JSON.parse(xhr.responseText),xhr)) } }; xhr.open('GET', url, true); xhr.send(null); }