也许我做错了什么,但尝试此示例在您的服务器/本地如果我有本地ajax.php文件并运行请求本地它的工作原理,但一旦ajax.php是远程它不会工作。为什么不在两个不同的服务器之间运行ajax?
<!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>
我该怎么办两个不同的服务器之间的AJAX? – 2011-05-07 16:14:15
看到我上面的修改。 – theomega 2011-05-07 16:15:12
谢谢,我发现这个网站http://sprain.ch/blog/2010/07/07/jsonp-jquery-and-php-make-cross-domain-ajax-calls-work/,我想知道为什么不能尝试$ .ajax而不是$ .getjson,它的工作原理,但我喜欢你给更多的网站上的例子。谢谢 – 2011-05-07 16:54:38