87,907
社区成员
发帖
与我相关
我的任务
分享
<script>
function ajaxtest(){
$.ajax({
type: "get",
url:"test.htm",
timeout: 5000,
data: {type:"info"},
cache:false,
success:function(xmlDoc, textStatus, xhr){
if(xhr.readyState==4)
{
if(xhr.status == 200)
{
var str=xhr.responseText; //获取返回值
}//200
}//4
},
error: function(xhr, textStatus, errorThrown)
{
if("timeout" == textStatus)
{
alert("请求超时");
}
else
{
alert("网络异常");
}
}
}); //ajax结束
}
</script>
function ajaxtest(url,data,callback){
$.ajax({
type: "get",
url:url,
timeout: 5000,
data: data,
cache:false,
success:function(xmlDoc, textStatus, xhr){
if(xhr.readyState==4)
{
if(xhr.status == 200)
{
var str=xhr.responseText; //获取返回值
if(callback){
callback(str);
}
}//200
}//4
},
error: function(xhr, textStatus, errorThrown)
{
if("timeout" == textStatus)
{
alert("请求超时");
}
else
{
alert("网络异常");
}
}
}); //ajax结束
}
function ajaxtest(url){
return $.ajax({
type: "get",
url:url,
timeout: 5000,
data: {type:"info"},
cache:false,
success:function(xmlDoc, textStatus, xhr){
if(xhr.readyState==4)
{
if(xhr.status == 200)
{
var str=xhr.responseText; //获取返回值
}//200
}//4
},
error: function(xhr, textStatus, errorThrown)
{
if("timeout" == textStatus)
{
alert("请求超时");
}
else
{
alert("网络异常");
}
}
}); //ajax结束
}