PDA

View Full Version : [CLOSED] Ext.ajax.Request -> always returns success



photon82
23 Aug 2011, 2:38 AM
Sencha Touch version tested:

1.10

Platform tested against:

Chrome 13.0.782.112 m on Windows

Description:

I noticed that, when using Ext.ajax.Request, the "success" function was always called, ignoring the actual status of success. When adding the callback function I do see the correct value of success returned.

Test Case:

Javascript code

function checkLoggedIn() {


var result = Ext.Ajax.request({
url: 'controllers/login.php',
failure: function(response, opts) {

},
success: function(response, opts) {

},
callback: function(options, success, response){

var data = Ext.decode(response.responseText);

if(data.success){

}
else{

}
}
});
};


PHP5


<?php

$return_json = '{"success": false}';
session_start();

echo $return_json;

?>

See this URL : not public
Steps to reproduce the problem:

Use the function above to call the PHP code

The result that was expected:

The "failure" function is called

The result that occurs instead:

The "success" function is called

Screenshot or Video:

no

Debugging already done:

none

Possible fix:

Using the callback method as work around.

mitchellsimoens
23 Aug 2011, 6:43 AM
Try returning error code other than 200... Return a 400 or 500 and see if success is true or false. The success in the response doesn't affect the success argument.

photon82
23 Aug 2011, 7:00 AM
Thanks for your reply.

This seems to be inconsistend with the functionality of a submit of a FormPanel. There the success function is called when succes: true and similar for the failure function. Is there any reason for this different approach?

mitchellsimoens
23 Aug 2011, 7:04 AM
Thanks for your reply.

This seems to be inconsistend with the functionality of a submit of a FormPanel. There the success function is called when succes: true and similar for the failure function. Is there any reason for this different approach?

They serve two different functions. FormPanel does extra processing and uses Ext.Ajax.request under the hood.

photon82
23 Aug 2011, 7:09 AM
I'll keep it in mind :)

You can close this thread.