jquery ajax封装问题 ajax封装 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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结束 } 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结束} jquery ajax已经封装的够通用了$.ajax$.post$.get$.getJSON$.getScript都可以用, 没有必要自己再去封闭一遍 为什么我的<marquee>只能循环一次就停了 代码如下 我想问下,我做一个图片更新的,前台能不能判断这个图片是否已经更新 想通过js自动提交表单,但是却不执行Onsubmit的事件,怎么办? 屏蔽javascript引和flash右键弹出的菜单? js缩放拖动图片功能,在图片超过2m时的问题 做自己的学习资料库 多个同名input,如何判断或定位当前的录入位置? 在网页中插入音频有什么好的办法吗?兼容ie7以上的 代码出错,帮忙看一下。 怎样才能让form 的select的滚动条变色? 懂支持SCORM课件的LMS开发的请进! office2007 automation 服务器不能创建对象
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结束
}
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结束
}
$.post
$.get
$.getJSON
$.getScript都可以用, 没有必要自己再去封闭一遍