爆出错误如下:
SyntaxError: missing } in XML expression
[在此错误处中断]
(<pre>{"msg":"ok","success":true}</pre>)
寻找了一下 发现 返回的 JSON中 被 <pre> </pre> 标签包裹着。
解决方法 两种
第一种: 后台添加一行代码:
response.setContentTypeIfNotSet("text/html");
第二种:前台重写Ext.form.Action.Submit
Ext.override(Ext.form.Action.Submit,{
// private
processResponse : function(response){
this.response = response;
//增加下面几句代码就OK啦
////////////////////////
var data = response.responseText;
if(data.indexOf('<pre>') != -1) {
response.responseText = data.substring(5, data.length-6);
this.response = Ext.util.JSON.decode (response.responseText);
}
///////////////////////////
if(!response.responseText){
return true;
}
this.result = this.handleResponse(response);
return this.result;
}
});
声明: 第一种本人使用 各个浏览器可以正常运行。 第二种时候发现只有FF浏览器可以。IE和谷歌依然不行。 所以最终使用了第一种。