写一个ajax funciton
function Ajax(url)
{
var m_xmlReq=null;
if(window.ActiveXObject)
{
try
{
m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e)
{
try{m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
}
}
else if(window.XMLHttpRequest)
{
m_xmlReq = new XMLHttpRequest();
}
this.post=function(d)
{
if(!m_xmlReq) return;
m_xmlReq.open('POST',url,false);
m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
m_xmlReq.send(d);
return eval(m_xmlReq.responseText);
}
}
相关文档:
结论:
jquery 1.3.2 ajax对编码问题进行过部分(见后面补充1 )处理,解决方案以jsp为例子:
ajax提交数据给jsp:ajax所在页面无任何要求,jsp页面需作两方面处理。
1.<%@page contentType="application/json" pageEncoding="UTF-8"%>或<%@page contentType="application/json" pageEncoding ......
jquery Ajax 传递汉字到 servlet 时出现乱码的问题
2009年11月25日 星期三 下午 02:28
jquery Ajax 传递汉字到 servlet 时出现乱码的问题
在js中对需要的传送的参数进行编码
encodeURI(encodeURI(param))
在服务器接受后对其进行解码
String param = URLDecoder.decode(request.getParameter("param"),"utf-8");
......
一.AjaxPro的使用
1.在项目中添加引用,浏览找到AjaxPro.2.dll文件
2.在Web.config中的system.web里面写入以下代码
</configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web> ......
Ajax的IE缓存问题,会造成用open时用get方法不能重复提交,导致获取不到实时的信息。解决的办法有以下几种:
1.客户端在url后添加随机数.
new Date().getTime()或者Math.Random()
或者送请求前加上
XMLHttpRequest.setRequestHeader("If-Modified-Since","0")
2.或者用post方法提交  ......
附spring整合DWR(包含struts1,spring,hibernate整合置):
http://blog.csdn.net/jiabeis/archive/2010/05/26/5626121.aspx
最近了解了一个有用的AJAX工具,看了网上的文章这里有一些摘抄和自己的总结,和大家分享:
什么是DWR(Direct Web Remote)?
DWR是一种AJAX解决方案!
DWR包括一个java库,以及一套javascript,使 ......