首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

jquey.post在firefox上返回值为xmlDocument的解决方法

2012-08-21 
jquey.post在firefox下返回值为xmlDocument的解决办法今天做项目,用jquery的ajax做了一把提交,$.post(./x

jquey.post在firefox下返回值为xmlDocument的解决办法

今天做项目,用jquery的ajax做了一把提交,

$.post("./xxx.do",{"userName":$("#userName").val()},function(msg){alert(msg)} );

?

Action里面设值

request.getWriter().write("_false");

request.getWriter().flush();

?

发现在IE、chrome下返回值皆正常,msg的值为_false

唯独在firefox下面返回值为一个xmlDocument对象,百思不得其解

然后对着API文档换回

$.ajax(url:"./xxx.do", data:{"userName":$("#userName").val()}, success:function(msg){alert(msg);},dataType:"html"),发现一切正常,恍然大悟,原来是post的时候没加dataType,加上之后

$.post("./xxx.do",{"userName":$("#userName").val()},function(msg){alert(msg)},"text" );或

$.post("./xxx.do",{"userName":$("#userName").val()},function(msg){alert(msg)},"html" );

果然一切正常

?

?

至于为什么不加dataType的时候IE和Chrome能正常解析,而firefox解析为xmlDocument,估计是各浏览器的默认设值不一样吧,不做深究

?

热点排行