无法从服务器获得答案。 ExtJS的

时间:2012-07-11 07:52:30

标签: javascript extjs

我在提交ExtJs表单时遇到问题。我无法获得success功能。

我有:

formp = new Ext.FormPanel({
 fileUpload: true,
 width: 350,
 autoHeight: true,
 bodyStyle: 'padding: 10px 10px 10px 10px;',
 labelWidth: 70,
 defaults: {
  anchor: '95%',
  allowBlank: false,
  msgTarget: 'side'
 },
 items:[{
xtype: 'fileuploadfield',
id: 'filedata',
emptyText: 'Выберите файл для загрузки...',
    fieldLabel: 'Имя файла',
buttonText: 'Обзор'
 }],
 buttons: [{
text: 'Загрузить',
handler: function(){
formp.getForm().submit({
  url: url_servlet+'doUpload.jsp',
  success: function(formp, o) {
      alert(o.responseText);    
      }
                                             })
                                            }
 }]
})
在doUpload.jsp中的

我有out.println("1111"); 在fireBug中,我看到doUpload.jsp POST 1111但没有提醒。怎么了?

1 个答案:

答案 0 :(得分:0)

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-submit

//Respone object
out.println("{success:true, file:'11111'}");

//Submitting the form. The second parameter in the success callback is
//your response object. You can access it properties as shown below.
formp.getForm().submit({
  url: url_servlet+'doUpload.jsp',
  success: function(formp, o) {
      alert(o.result.file);    
  }
});