PDA

View Full Version : How to get response from submit ??



gerome45
10 Nov 2011, 1:18 AM
Hy all,
First you'll have to excuse me for the english, i'm not realy good !!!

I have a form with an user, password and an url.


var logform = new Ext.FormPanel ({ labelWidth:80,
bodyStyle:"background-color:#dfe8f7",
defaultType:'textfield',
monitorValid:true,
items:[{
fieldLabel:'Url',
name:'url',
value:'http://localhost:8080/geoserver/wms?request=getCapabilities',
hidden:true,
},{
fieldLabel:'Utilisateur',
name:'username',
allowBlank:false
},{
fieldLabel:'Mot de passe',
name:'password',
inputType:'password',
allowBlank:false
}],

I submit the form with au button



buttons:[{
text:'Se connecter',
formBind: true,
handler:function(){
//alert(logform.items.items[0].el.dom.value);
//var pass = logform.items.items[1].el.dom.value;
logform.getForm().submit({
url:'http://localhost:8080/geoserver/TestWfsPost',
method:'POST',

});

},

},{
text:'Annuler',
handler:function(){
// envoi sur le moteur de recherche google
//document.href = "http://www.google.fr";
log.hide();
},
}],

When I debut in chrome, I can see the response (an xml).

I would like to get this response in my application.

Do you have an Idea ??

Uberdude
10 Nov 2011, 3:45 AM
logform.getForm().submit({
url:'http://localhost:8080/geoserver/TestWfsPost',
method:'POST',
success: function(form, action) {
// process response ...
}
});

Check the docs for details of the response passed to the success callback.

gerome45
10 Nov 2011, 4:56 AM
right, thank you for the answer bur I have a problème with my script :



Ext.onReady(function() {


/*****************************************************************************************
*initialisations diverses
*
*****************************************************************************************/
logok = false;
Ext.QuickTips.init();

/*****************************************************************************************
*page de login
*
*****************************************************************************************/

var logform = new Ext.form.FormPanel ({
labelWidth:80,
bodyStyle:"background-color:#dfe8f7",
defaultType:'textfield',
monitorValid:true,
items:[{
fieldLabel:'Url',
name:'url',
value:'http://localhost:8080/geoserver/wms?request=getCapabilities',
hidden:true,
},{
fieldLabel:'Utilisateur',
name:'username',
allowBlank:false
},{
fieldLabel:'Mot de passe',
name:'password',
inputType:'password',
allowBlank:false
}],
buttons:[{
text:'Se connecter',
formBind: true,
handler:function(){
//alert(logform.items.items[0].el.dom.value);
//var pass = logform.items.items[1].el.dom.value;
logform.getForm().submit({
url:'http://localhost:8080/geoserver/TestWfsPost',
method:'GET',
success : function(form, action) {
alert(action);
}
});

},

},{
text:'Annuler',
handler:function(){
// envoi sur le moteur de recherche google
//document.href = "http://www.google.fr";
log.hide();
},
}],
});

var log = new Ext.Window ({
modal : true,
title : "Identifiez-vous !!",
closeAction : 'hide',
layout : 'fit',
width:300,
height:150,
items : [logform]
});

log.show();
});

When I load this page, I have an excpetion

ext-all.js:7 (http://localhost:8080/geoserver/www/ext-3.3.1/ext-all.js)
Uncaught SyntaxError: Unexpected token <

but, the debugger, show me the response.
the error is just befor

success : function(form, action) { alert(action);
}


So I can never pass in the success case.

Thanks for your help, as you can see, i'm not very good in javascript too.