Error with jQuery.load () only in Safari (OSX)

0

I have a problem using jquery.load () p to load part of another document that only occurs in Safari on the Mac (in the latest versions: Safari 7.1 and OSx 10.9.5). In all other browsers (including IE) they work perfectly.

The error in the Safari console I receive is as follows:

XMLHttpRequest can not load link . Origin link is not allowed by Access-Control-Allow-Origin

So I researched this error when there is a request in ajax between two different domains. Although all the files are in the same domain and in the same folder, because of the error that is shown, the source domain and the one trying to load the file have a small difference: one of them is without WWW > and probably what is causing the error.

The code I am using to load is as follows:

$('.holder').load("arquivo_a_ser_carregado.php #conteudoPort",function(){ 
    console.log('ok'); 
});

As I said earlier, this error is only occurring in Safari on Mac. Even putting the absolute url keeps getting the same error.

If someone has already gone through this and has some light to help me, thank you very much. Thank you very much.

    
asked by anonymous 10.10.2014 / 19:13

1 answer

1

If you have control of the server that responds to the ajax request, try to configure the response header with:

Access-Control-Allow-Origin: *

Even small variations such as www can influence how the browser identifies the domain.

Since you are using php, you can also try using:

<?php header('Access-Control-Allow-Origin: *'); ?>

Attention to * . Replace it as needed, otherwise your domain will accept requests from any other domain.

    
07.01.2015 / 20:38