It works fine when I test my application on devices and on the xcode simulators but in web browsers such as Chrome and Safari, the failure function gets called. I don't think the Same-Origin Policy applies here because I tried doing the same thing using jquery's $.ajax and it worked fine.
here is my code :
Code:
// send ajax request
Ext.Ajax.request({
url: 'http://testapp.cloudapp.net/index.php/api/accounts/login/',
method: 'POST',
params: {
username: Ext.getCmp('username').getValue(),
password: Ext.getCmp('password').getValue()
},
dataType: 'json',
success : function(response, request) {
if(response.responseText == true) {
Ext.Msg.alert('validated');
// animate to wall view
Ext.Viewport.animateActiveItem(targetView, { type : 'fade' } );
//destroy Login and Register Views
var vwRegister = Ext.ComponentQuery.query('register')[0],
vwLogin = Ext.ComponentQuery.query('login')[0];
setTimeout( function() {
vwRegister.destroy();
vwLogin.destroy();
}, 2000);
}
else {
Ext.Msg.alert('invalid user');
}
},
failure: function(response, request) {
Ext.Msg.alert('error');
}
});