ExtJS4.0 文件上传的返回JSON字符串不对 - Web 开发 / Ajax
最近使用ExtJS4.0做项目,在ExtJS上传文件时发现上传成功后,ExtJS对返回的JSON字符处理报异常,而字符串的被加入了<pre></pre>,可是以为服务端返回问题,原来使用Spring的上传功能,后改用Servlet上传,ExtJS接收也是会有这样的问题,下面是ExtJS的页面代码:
var form =Ext.create('Ext.form.Panel', { id:'image_up', frame : true, buttonAlign : 'center', fileUpload: true, //上传文件 scope : this, renderTo:Ext.getBody(), items : [ { fieldLabel : '上传图片', labelAlign:'right', name : 'imgFile', id : 'imgFile', xtype : 'filefield', labelWidth : 60, archor:'100%', width:350, height:25, buttonText:'选择图片……', colspan:2 }], buttons : [ { text : '提交', handler : function() { form.form.submit({ clientValidation : true, url : 'TestUpload', method : 'POST', waitMsg:'正在上传图片', success : function(form, action) { var data = Ext.JSON.decode(action.response.responseText).data; Ext.Msg.alert('提示', '添加成功'); window.close(); }, failure : function() { var data = Ext.JSON.decode(action.response.responseText); Ext.Msg.alert('提示', data.errors); } }); } }, { text : '重置', handler : function() { reset(form); } } ] }); });
[解决办法]
这个就晓不得了。。感觉ext没这么傻吧。。自动增加pre标签。