我正在尝试使用 AJAX 从 URL 获取信息。这个 URL 将返回一个 JSON 响应,但我在让它工作时遇到了很多麻烦。我对同时使用 AJAX 和 JSON 还很陌生,所以我不太确定自己做错了什么。我没有收到任何输出。这是我到目前为止所拥有的:
HTML:
<!doctype html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content - Type">
<meta content ="utf-8" http-equiv="encoding">
<title>My Javascript Practice</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<noscript>JavaScript Must Be Enabled</noscript>
</head>
<body>
<div id="pub">Parent Div</div>
<script type="text/javascript" src="getList.js"></script>
</body>
</html>
JavaScript:
var teamId = 883455;
var myUrl = "https://apps-internal.attributor.com/guardianapi/service/csadminservice/csteams/" + teamId + "?view=PUBLISHERS_FOR_TEAM";
$.get(myUrl, function(data){
$("#pub").html(data);
alert("load was performed");
});