+ -
当前位置:首页 → 问答吧 → 请问高人有没有办法改造这个函数让其能返回服务端响应数据response

请问高人有没有办法改造这个函数让其能返回服务端响应数据response

时间:2010-12-04

来源:互联网

function sendRequest(url)
{
var xhr=createXHR();
var response="hi";
xhr.open("get",url,true);
xhr.onreadstatechange=function(){
if(xhr.readState==4 && xhr.status==200)
{
response=xhr.requestText;
}
};
xhr.send(null);
return response;
}

作者: JIANGFEIMAIL   发布时间: 2010-12-04

function sendRequest(url)
{
var xhr=createXHR();
var response="hi";
xhr.open("get",url,true);
xhr.onreadstatechange=function(){
if(xhr.readState==4 && xhr.status==200)
{
response=xhr.requestText;
alert(response); 在这里处理就可以了
}
};
xhr.send(null);
//return response;
}

用回调函数!

作者: hch126163   发布时间: 2010-12-05

热门下载

更多