原生js访问json

来源:互联网 发布:印度同志聊天软件 编辑:程序博客网 时间:2024/05/01 18:18
var xml;if (window.XMLHttpRequest) {  xml = new XMLHttpRequest();  }else if(window.ActiveXObjec) {  xml = new ActiveXObject("Microsoft.XMLHTTP");  }if (xml != null) {xml.onreadystatechange = function() {if (xml.readyState == 4 && xml.status == 200) {var obj = JSON.parse(xml.responseText);for(var name in obj){console.log(obj[name])}}}xml.open("POST","index.php",true);xml.send();}

0 0
原创粉丝点击