Converting AJAX call to avoid cross-domain problems

Go To StackoverFlow.com

0

I m trying to convert the following code to another AJAX call, in order to not have cross-domain problems!

This is my original code:

<script>   
        $(document).ready(function() {
            $("#os").load('http://www.a.gr/os #livesos');
            var refreshId = setInterval(function() {
               $("#os").load('http://www.a.gr/os #livesos');
            }, 60000);
            $.ajaxSetup({ cache: false });
        });     
</script>

And here is a sample code for what i want to do, but i dont know how...

$.ajax({
type: "GET",
cache: false,
url: 'http://www.a.gr/os',
dataType: "???",
.
.
.
.
});

Can someone help me please?

2012-04-04 01:32
by zuperakos
If your javascript is not from www.a.gr then you will still have a problem - James Black 2012-04-04 01:36
and what should i do? i want to use this code in phonegap for iphone app.. - zuperakos 2012-04-04 01:37


0

Your best bet to avoid cross-domain issues is to have the phone call your server, and the server can call the other servers to get the data needed.

There are a couple of benefits to this, one being that you can cache recent calls, if it doesn't change often, and more quickly send it back to the client.

Also, if you want to later change the url or make additional calls to return richer data, you can do that without affecting the client.

2012-04-04 01:44
by James Black
Thank you for your reply! Could you give some info how i can do this? : - zuperakos 2012-04-04 01:48
Rather than making a url connection to www.a.gr, just have it make a get/post request to your server, and your server would then need to make these calls - James Black 2012-04-04 12:13
Ads