XMLHttpRequest and Phonegap ... Is the policy of origin or not?

I'm still new to Phonegap, and now I'm working with the Android SDK. At least I wanted to do XMLHttpRequest to retrieve data from my server. I used to know about the same origin policy, and I asked myself how this should work with the “native application”.

I searched the Internet and found some topics where people told others that Phonegap doesn’t have a policy of the same origin, because it uses the file:// protocol and, in addition, it has a whitelist for the domain config.xml .

On the other hand, there were many topics of people having problems with XHR, while others told them that this was due to the same origin policy ...

Well, I was confused, but I used my regular websites - I worked out the XMLHttpRequest snippet and put it in the Phonegap application. I tried a virtual device, but my request is not working.

Now I asked myself a few questions:

  • Who is right? Is there the same origin policy in Phonegap or not?

If yes:

  • What function does this whitelist have?

  • What is the best way to get my server data?

+8
same-origin-policy cordova
source share
1 answer

Yes, people are right. A policy of the same origin is only needed in webApps applications, not hybrid phone records.

You need to check the domain whitelist, just check it in the config.xml folder in res xml .

To access the xml web services, you need to make sure your soap message is well-formed. try to catch the exact mistake.

+5
source

All Articles