示例如下:
this.form.getForm().submit({
waitTitle : '請稍后...',
waitMsg : '正在保存菜譜信息,請稍后...',
url: '../cookbook',
method: 'POST',
success: this.addCookbook,
failure: function(form, action) {
DelayMessage.show("系統消息", action.failureType);
},
scope: this
});
開始的時候,從服務器端返回JSON數據的時候,直接彈出下載提示對話框,success函數從來不執行。
不明白什么原因。
經過在EXT JS官方論壇上查找,發現有如下解釋:
Your server needs to return a page with Content-type:text/html (so NOT application/json!).
Also, since it's HTML the response should be:
HTML Code:
<html><body>{success:true}</body></html>
于是,我修改服務器端返回,由原來的application/json返回,改成html返回,并且,按照數據規定格式寫。
注意:返回的html中,必須帶success:true參數。如果要回傳其他數據,請在后面加上對應的數據即可。如下:
<html><body>{success:true,cookbook:[{name:"gbjd"},{name:"szr"}]}</body></html>