I'm still new to Phonegap and I am working with the Android SDK for some days now. At least I wanted to do a XMLHttpRequest
to get data from my server.
I knew about the Same Origin Policy before and I asked myself, how this should work with a "native app".
I searched the internet and found some topics, where people were telling others, that there is no Same Origin Policy on Phonegap, because it uses the file://
protocol and additionally there is a domain whitelist in it's config.xml
.
On the other hand there were a bunch of topics of people having problems with XHR's and others told them, that this is because of the Same Origin Policy...
Well, I was confused, but I used my - on regular websites - working XMLHttpRequest
snippet and put it into the Phonegap app. I tried the virtual device, but my request is not working.
Now I asked myself some questions:
If yes:
What function has that domain whitelist?
What's the best way to still get the data of my server?
Yes, people are correct the Same Origin Policy is needed only in webApps not hybrid phonegap apps.
You need to check you domain whitelist, just check it in the config.xml
in res
--> xml
folder.
For accessing xml web services you need to ensure your soap message is correctly formed. try to catch the exact error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With