52,797
社区成员
发帖
与我相关
我的任务
分享
<%
response.AddHeader "pragma","no-cache"
response.AddHeader "cache-control","no-cache"
response.AddHeader "expires","0"
response.Write now
%>
如果是静态页,需要加上禁止缓存的meta,就需要自己分析返回的数据提取需要的内容了
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
[quote=引用 18 楼 maco_wang 的回复:] 我对ajax不太了解 1.纯js写的ajax 2.多年前用过这种: <httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/> </httpHandlers> 后台方法前面+[AjaxPro.AjaxMethod]。 3.多年前用过UpdatePanel控件。 4. 后来用过这种 $(document).ready(function(){ $("#b01").click(function(){ htmlobj=$.ajax({url:"/jquery/test1.txt",async:false}); $("#myDiv").html(htmlobj.responseText); }); }); 5.波波,现在最新的是什么样子的?
我对ajax不太了解 1.纯js写的ajax 2.多年前用过这种: <httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/> </httpHandlers> 后台方法前面+[AjaxPro.AjaxMethod]。 3.多年前用过UpdatePanel控件。 4. 后来用过这种 $(document).ready(function(){ $("#b01").click(function(){ htmlobj=$.ajax({url:"/jquery/test1.txt",async:false}); $("#myDiv").html(htmlobj.responseText); }); }); 5.波波,现在最新的是什么样子的?
var xhr=window.XMLHttpRequest?new XMLHttpRequest():new window.ActiveXObject("microsoft.xmlhttp"):false;
if(xhr){
xhr.onreadystatechange=function(){
if(xhr.readyState==4){//需要为4数据解析完毕后才能获取,支持steaming ajax的readyState为3就可以获取了,不支持的会保存,所以还是为4时才获取
if(200==xhr.status||0==xhr.status){
var data=xhr.responseText;//如果请求xml格式的内容,响应头为text/xml,可以使用xhr.responseXML得到xml document对象
//后续的处理,如eval处理成JSON对象或者split才分成数据什么的,根据动态页返回的数据
}
else alert('请求的页面有问题\nstatus:'+xhr.status+'\n'+xhr.responseText);
}
}
xhr.open("get","url地址",true);
xhr.send(null);
}
else alert('浏览器不支持ajax(⊙o⊙)哦!');
2,使用的是ajaxpro,需要结合asp.net,以前也有用过,写了些小总结,嘿嘿。
3,微软的,不太了解生成的客户端js类库结构,不过提供的无刷新方法,都是居于XMLHttpRequest或者activexobject来实现的,只是做了打包,方便调用
4,jquery框架,和3一样对ajax对象进行了打包,最好还是不要设置async:false启用同步请求,网速慢浏览器假死体验很差,同步请求实现的,都可以通过异步+回调来解决。
5,如何写主要还是依赖使用哪个类库,2,3,4都是使用底层的ajax对象来实现无刷新,如果用Ext,还可以
Ext.Ajax.request({
url: 'page.php',
params: {
id: 1
},
success: function(response){
var text = response.responseText;
// process server response here
}
});
不过为了使用ajax倒入ext框架就有点大材小用。。O(∩_∩)O~
相关参考
ajax问题总结
ajax对象常用属性,事件,方法大小写问题的总结
ajax onreadystatechange状态转换函数研究
firefox下XMLHttpRequest重用时nsIXMLHttpRequest.send发生错误的解决方案
firefox Streaming AJAX实现源代码
ajaxpro使用总结[/quote]真是用心啊 ,,膜拜[quote=引用 14 楼 lenj520 的回复:] 大神 请指教 $("#fileImg").uploadify({ 'uploader' : './swf/uploadify.swf', //flash文件的相对路径 'buttonText': 'BROWSE', 'method': 'post', 'script' : './upload.action', //后台处理程序的相对路径 'cancelImg' : './images/cancel.png', //每一个文件上的关闭按钮图标 'auto': true, 'multi': false, 'fileDataName': 'fileImg', 'fileExt': '*.jpg;*.gif', 'onComplete': function (event, queueID, fileObj, response, data) { var index =GetIndex(); //该方法获取的参数是正确的 alert(index); //弹出的值正确无误 $("#fileImg").uploadifySettings('scriptData',{'index': index}); if (response && response.length > 0) { var stringArray = response.split("|"); if (stringArray[0] == "1") { $("#imgReview").attr("src", stringArray[1]); $("#imgFrame" + index).attr("src", stringArray[1]); var imgInfo = "格式:" + fileObj.type + " 大小:" + (parseFloat(fileObj.size) / 1024).toFixed(2) + "KB"; $("#imgInfo").html(imgInfo); $("#HidImgInf" + index).val(imgInfo); $("#HidImg" + index).val(stringArray[1]); $("#optype" + index).val("1"); } else { alert("对不起,上传出错。原因:" + stringArray[2]); } } } }); action取值方式: String index=request.getParameter("index"); 1.index 通过getindex()能获取到正确的值 2.通过红色的部分 把index这个参数传到 ACTION里面去 第一获取的到始终是空置 3.再次执行的时候 获取到的值是首次执行的值。 请问是什么原因呢? 该如何修改?