XMLHttpRequest函数

function createXmlHttpRequest(){
if(window.ActiveXObject){
return new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
return new XMLHttpRequest();
}
}
(function(){
var url = "/ordermgr/a.txt";
xmlHttpRequest = createXmlHttpRequest();
xmlHttpRequest.onreadystatechange = goods;
xmlHttpRequest.open("GET",url,true);
xmlHttpRequest.send(null);
})();
function goods(){
if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
var data = xmlHttpRequest.responseText;
data = strToJson(data);
dom.innerHTML = $formatTpl(tp.goodsList,{list:data.list})
}
}
function strToJson(str){
var json = (new Function("return " + str))();
return json;
}

上一篇:mongo DB for C#


下一篇:mongodb 面试题总结