Fabi
Fabi

Reputation: 274

XMLHttpRequest and Phonegap... Same Origin Policy or not?

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:

Upvotes: 8

Views: 5312

Answers (1)

Sheetal
Sheetal

Reputation: 1366

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.

Upvotes: 5

Related Questions