maybe im doing something wrong but try this sample on your server/local if i have the ajax.php file local and run the request local it works but once the ajax.php is remote it wont work.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p></p>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
window.setInterval(function()
{
$.ajax({
url: 'ajax.php',
type: 'GET',
dataType: 'json',
cache: false,
success: function(result)
{
$('p').html(result.price);
}
});
}, 2000);
});
</script>
</body>
</html>
JavaScript can only load data from the same host, this is called SameOrginPolicy. In short, this roughly means that a JavaScript Code embedded in a HTML-File on
ServerAcan only requests documents fromServerAvia AJAX. This is done for security reasons.If you really need to load data from a external server, you can try to use JSONP. Examples can be found via Google, for example here.