This is because the meusiteaqui.com is not authorizing, there are two solutions:
1. Authorize via Header:
You need to add that:
<?
header("Access-Control-Allow-Origin: *");
//...
?>
On the page in question, to allow the connection of any other site, including the localhost. Some browsers may continue to prevent this for security reasons.
You can also do this in htaccess, for example:
<FilesMatch "\.(php|html|htm)$">
<IfModule mod_headers>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
2. Use the JSONP:
Modify your PHP to something similar:
$seusDados = array('id' => 1);
// Exemplo
$seuJSON = json_encode($seusDados);
if(isset($_GET['jsonp'])){
echo $_GET['jsonp'] . '(' . $seuJSON . ')';
}else{
echo $seuJSON;
}
You can use something similar to:
<script>
MinhaResposta(MeuJSONP){
alert(MeuJSONP.id)
}
</script>
<script type="text/javascript" src="http://meusiteaqui.com?jsonp=MinhaResposta"></script>
If you want to know more about JSONP click here.
Enter the error message to facilitate help.
– rubStackOverflow