Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Same Origin Policy in Mobile Safari

I have an HTML5/JavaScript app that was originally written to run in certain cars. Basically, I need to set up my app to run in the browser for a simple demo to a customer.

I'm using jQuery .ajax which is causing problems due to the Same Origin Policy. I have found plenty of ways to disable this in desktop browsers, but not mobile ones.

My goal is to demo the app on an iPad in Mobile Safari. Is there any way to temporarily disable the Same Origin Policy on an iPad?

like image 786
Danny Avatar asked Aug 27 '12 22:08

Danny


1 Answers

I had the same problem with a sencha app. I resolved by setting a base path to my javascript ajax calls, example:

var BASEPATH = 'http://192.168.1.200/myapp';

$.ajax({
  url: BASEPATH+'/someaction'
});

And from the mobile I access it with http://192.168.1.200/myapp

My problem was that the from mobile I get access only with IP but ajax call were point to localhost.

Hope this trick helps.

like image 122
albanx Avatar answered Oct 06 '22 00:10

albanx