如何通过Ajax实现无依赖数据获取的技巧?
- 内容介绍
- 文章标签
- 相关推荐
本文共计120个文字,预计阅读时间需要1分钟。
代码输出: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) { } } }
代码出处:github.com/jaywcjlove/FED1.[代码]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); }
本文共计120个文字,预计阅读时间需要1分钟。
代码输出: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) { } } }
代码出处:github.com/jaywcjlove/FED1.[代码]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); }

