PDA

View Full Version : Ajax handler arguments



Oliver Specht
2 Jul 2010, 4:49 AM
Hi,
I want to create a function which parses my ajax responses.

Now I am wondering which arguments the handler function gets?

I read http://dev.extjs.com/learn/Manual:Core:Ext.Ajax but that does not seem to be correct, because when I look at the arguments I have some form object as first argument (arg1). The second argument (arg2) contains a "response" and "options" attribute.

How can that be? And what is correct now?

My code:


function handleSuccessFailure(arg1, arg2)
{
console.log(response);
}


addUserForm.addButton({
text: 'Speichern',
formBind: true,
handler: function () {
addUserForm.getForm().submit({
waitMsg: 'Daten werden gesendet...',
success:handleSuccessFailure,
failure:handleSuccessFailure
....

Condor
2 Jul 2010, 4:57 AM
These are not the same methods!

An Ext.Ajax.request success handler has response and options parameters.
An Ext.form.BasicForm.submit success handler has form and action parameters.

2 Jul 2010, 6:06 AM
Hi,
I want to create a function which parses my ajax responses.

Now I am wondering which arguments the handler function gets?

I read http://dev.extjs.com/learn/Manual:Core:Ext.Ajax but that does not seem to be correct, because when I look at the arguments I have some form object as first argument (arg1). The second argument (arg2) contains a "response" and "options" attribute.

How can that be? And what is correct now?

My code:


function handleSuccessFailure(arg1, arg2)
{
console.log(response);
}


addUserForm.addButton({
text: 'Speichern',
formBind: true,
handler: function () {
addUserForm.getForm().submit({
waitMsg: 'Daten werden gesendet...',
success:handleSuccessFailure,
failure:handleSuccessFailure
....
I wrote that page. it is correct. It's your understanding of the framework that is incorrect. ;)

Oliver Specht
4 Jul 2010, 3:50 AM
@Condor:
Thanks, I just didn't notice that...

@jgarcia:
I just wondered and did not want to state that it is wrong, sorry, if it sounded like that.

It is really hard to "understand" the ext framework, because the docs and tutorials are spread anywhere and if I take a look at http://dev.extjs.com/learn/Manual:Forms:BasicForm how should one understand how to work with BasicForms?!?

Exception is the AJAX page of course ;) and the API Docs...