if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); //for chrome or ie8 and gr eater else xhr = new ActiveXObject("Microsoft.XMLHTTP"); // for ie6 and7
解析(parse)
chrome 可用JSON.parse,IE会收到错误 JSON未定义
,前后加括号直接转换就行。
1 2 3 4
if(typeof(JSON)=='undefined') var obj = eval("(" + responseText + ")"); else var obj = JSON.parse(responseText);