I have a simple workaround which works for Angular.js within PhoneGap 3:
If your development machine such as a laptop is online through a cable modem or wireless network,
just do ipconfig, get the preferred IP, and then make your server run on that IP, with any port you wish.
Then the $resource call will work. ***** $resource just seems to hate 127. anything. ****
(I previously tried serving on 127.0.0.2 (suspecting only 127.0.0.1 is the issue) but still not joy...)
For example my laptop is connected on line through my AT&T private Hot Spot
So I did.
C:>ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : lan
Link-local IPv6 Address . . . . . : fe80::1d55:b740:cf2f:b19a%13
IPv4 Address. . . . . . . . . . . : 192.168.1.40
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
So I started up my python web2py backend development server on my laptop (based on the Rocket python server) to server at
http://192.168.1.40:8080(It is actually web2py in the Google App Engine dev_appserver)
Now this $resource call works for me from my Android app:
get: { method: 'GET' },
query: { method: 'GET', isArray: true}
});
Result in Chrome Debugger:
XHR finished loading: "file:///android_asset/www/views/ViewPerson.html". vendor.89a83346.js:4
Here is the XHR Detail:
Request Method:GET
Status Code:303 OK
Request Headersview source
Accept:application/json, text/plain, */*
Cache-Control:no-cache
Pragma:no-cache
User-Agent:Mozilla/5.0 (Linux; Android 4.4.2; Android SDK built for x86 Build/KK) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/
30.0.0.0 Mobile Safari/537.36
Query String Parametersview sourceview URL encoded
id:1
Response Headersview source
Cache-Control:no-cache
Content-Length:67
Content-Type:text/html; charset=UTF-8
Date:Sun, 27 Jul 2014 16:25:08 GMT
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Location:/init/default/wiki/main
Server:Development/1.0
NOTE: As you can see, there is no issue of any 'X-Requested-With' header. I did not need any code to deal with it because it is not there fortunately.
Cheers!