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,估计是各浏览器的默认设值不一样吧,不做深究

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值