【发布时间】:2014-04-05 01:44:48
【问题描述】:
我直接从 w3 学校示例中获取了此代码,但是,在他们的“Tryit 编辑器”之外,它对我不起作用。有什么想法吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
$.getJSON("http://w3schools.com/jquery/demo_ajax_json.js", function (result) {
$.each(result, function (i, field) {
$("div").append(field + " ");
});
});
});
});
</script>
</head>
<body>
<button>Get JSON data</button>
<div></div>
</body>
</html>
【问题讨论】:
-
另外,avoid using w3schools 也是个好主意。
-
->en.wikipedia.org/wiki/Same_origin_policy<-