PDA

View Full Version : Sencha Touch / PhoneGap / Ajax calls



dalenz
27 Aug 2012, 1:37 PM
Hello,


I have a Sencha Touch web app that runs on local server just fine.
The web app makes login ajax call to http://localhost using Ext.Ajax.request with POST method.




var lform = button.up('login_form');
var values = lform.getValues();


Ext.Ajax.request({
url : "http://localhost:8080/myapp/assets/www/api/login.php",
params : values,
method: "POST",

success: function(response) {
alert("SUCCESS");
},
failure: function(response) {
alert("FAILURE");
}



After, I converted the web app into a native Android app via PhoneGap.



When I run the application, I don't get error messages, but it seems not to detect the file login.php (I'm using android emulator 4.0.3).
What am I doing wrong?


I entered <access origin=".*"/> into config.xml.


Thanks,
David

baljit4495
28 Aug 2012, 12:43 AM
this through the simulator ?

dalenz
28 Aug 2012, 1:13 AM
Yes, I'm using an Android emulator 4.0.3.

steve1964
28 Aug 2012, 1:24 AM
Hi, you cant access localhost form the device in this way, you have to put your php on a pubblic ip or just read this http://stackoverflow.com/questions/2234742/test-the-localhost-in-android-emulator

(http://stackoverflow.com/questions/2234742/test-the-localhost-in-android-emulator)

baljit4495
28 Aug 2012, 2:03 AM
or you could try and open up google chrome without web security, for testing

if your using mac use this command

open /Applications/Google\ Chrome.app --args --disable-web-security

steve1964
28 Aug 2012, 2:11 AM
Hi baljit4495 (http://www.sencha.com/forum/member.php?485361-baljit4495) , if using Phnegap simply you cant, because Phonegap run app in a webview

baljit4495
28 Aug 2012, 5:13 AM
then the original suggestion of placing the files on a live server would probably be the best option here

steve1964
28 Aug 2012, 5:24 AM
Is the only option if he want to go live on Google play market....