-
11 Mar 2008 5:23 AM #1
Ajax Request Failure
Ajax Request Failure
Hi, I am using Ext Js in my Air app., while making Ajax requests, the request fails once or twice, but after that the requests are normal, below is the code with which i am making the request.
Any ideas about what I am doing wrong here ?
Code:Ext.onReady(function() { Ext.get('myButton').on('click', function(){ Ext.Ajax.request({ url: 'http://localhost/testcontroller/get_data/', method: "POST", params: 'name=testval', success: function( r, o ){ alert('Success'+ r.responseText ); }, failure: function( r, o ) { alert( "fail: " + r.responseText ); } }); }); });
-
31 Mar 2009 7:02 AM #2ralmeidaGuest
I am having a similar issue, to help debug this I am using a localhost server. I run my air app and to check if the Ajax calls are even making it to the server you can check your access logs. If they are you can use a tool like Aptana to see what is coming back form the server via the air.trace method.
The issue I am having is that the response is good but for some reason EXT is not getting the data or not using what is given to it. I've made sure I've included all the required air files, not too sure where to go from there.
-
1 Apr 2009 1:11 AM #3
I make extensive use of Ajax calls in my AIR applications and had never such a problem. But I do not use the success and failure properties but instead the callback property to define one method which also does the error check. Maybe your problem is related to this issue.
Regards Rob
-
1 Apr 2009 4:30 PM #4ralmeidaGuest
Thank you very much! That was the issue, so using air and making the ajax calls you have to use the callback vs. the built in success / failure functions.
-
1 Apr 2009 4:35 PM #5ralmeidaGuest
So this may help with your ajax request in air
Code:Ext.onReady(function() { Ext.get('myButton').on('click', function(){ Ext.Ajax.request({ url: 'http://localhost/testcontroller/get_data/', method: "POST", params: 'name=testval', callback: function(opt,success,responseObj) { if (success) { // Yay // server data var responseData = Ext.util.JSON.decode(responseObj.responseText); var data = responseData.data; } else { // AJAX Fail } } }); }); });


Reply With Quote