读书人

jquery iE 不兼容有关问题,求解

发布时间: 2013-10-04 21:41:43 作者: rapoo

jquery iE 不兼容问题,求解
struts2 返回json数据,页面一个form 表单,包含简单文本,及若干file 上传.火狐,谷歌功能正常,ie 老提示下载.不说了,贴源码...
struts2 配置:

 
<package name="/product/json" extends="json-noprotected-default">
<action name="*" method="{1}" class="com.test.fund.web.action.product.FundProductAction">
<result type="json">
<param name="ignoreHierarchy">true</param>
<param name="excludeNullProperties">true</param>
<param name="root">msg</param>
</result>
</action>
</package>


Action 代码:
private String msg ;
public String test(){
msg="成功";
return SUCCESS;
}

页面代码:
form 表单....
script:

jQuery("#mainForm").ajaxSubmit({
url:'/product/json/doUpdateFundProduct.action',
dataType:'json',
type:'POST',
success:function(json){
alert(json);
},
error:function(){
alert("error");
}
});
jquery struts2 json ?IE
[解决办法]
ie10,ie11下有该问题,原因与浏览器机制有关,不支持json型response,就会提示下载,
解决方法是修改返回头信息的content-type为text/html

读书人网 >跨浏览器开发

热点推荐