我无法从以下代码中打印出成功的结果,包括这一行jQuery.support.cors = true;会出现警告消息。那么我该如何避免这种情况而不失去功能呢?我的主要目标是调用返回JSON数据的REST Web服务并利用该数据。请帮我解决这个问题并提供一个可行的示例。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.getJSON demo</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<script>
jQuery.support.cors = true;
$.ajax ({
url: 'http://json-cricket.appspot.com/score.json',
datatype: "json",
success: function (e) {
// Success callback
alert("sucess");
}})
</script>
</body>
</html>
dataType
而不是全部小写,但不确定这会有多大的区别,如果 jQuery 可以处理它或者我记错了。http://api.jquery.com/jQuery.ajax/ - martincarlin87