2012-07-11 75 views
1

我在提交ExtJs表单时遇到问题。我无法获得success函数。无法从服务器获得答案。 ExtJs

我:

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,但没有一个警报。怎么了?

+0

CON你告诉我们,充分反应? – Thariama 2012-07-11 08:00:10

+0

out.println(“1111”);这就是全部。或者你问别的什么? – 2012-07-11 08:03:20

+0

好吧,那不是什么 – Thariama 2012-07-11 08:03:47

回答

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);  
    } 
}); 
+0

我不知道谁降级好的代码? – 2012-07-13 11:06:14