示例如下:
this.form.getForm().submit({
waitTitle : '請稍后...',
waitMsg : '正在保存菜譜信息,請稍后...',
url: '../cookbook',
method: 'POST',
success: this.addCookbook,
failure: function(form, action) {
DelayMessage.show("系統(tǒng)消息", action.failureType);
},
scope: this
});
開始的時候,從服務(wù)器端返回JSON數(shù)據(jù)的時候,直接彈出下載提示對話框,success函數(shù)從來不執(zhí)行。
不明白什么原因。
經(jīng)過在EXT JS官方論壇上查找,發(fā)現(xiàn)有如下解釋:
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>
于是,我修改服務(wù)器端返回,由原來的application/json返回,改成html返回,并且,按照數(shù)據(jù)規(guī)定格式寫。
注意:返回的html中,必須帶success:true參數(shù)。如果要回傳其他數(shù)據(jù),請在后面加上對應(yīng)的數(shù)據(jù)即可。如下:
<html><body>{success:true,cookbook:[{name:"gbjd"},{name:"szr"}]}</body></html>