【发布时间】:2014-04-09 18:01:30
【问题描述】:
我正在尝试解析一个 Json,它是 here。当我启动浏览器时,2 秒后,出现错误:
资源被解释为脚本,但以 MIME 类型 text/html 传输:
为什么?这是什么错误?
JS
function example()
{
alert("hello nice");
var URL = "http://sath3g.altervista.org/index.php";
$.ajax(URL, {
crossDomain: true,
dataType: "jsonP",
type: 'GET',
success: function (data, text, xhqr) {
$.each(data, function(i, item) {
alert(item);
});
},
});
}
HTML
<!DOCTYPE html>
<html>
<head>
<title>Parse Json</title>
<script src="parse.js"></script>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
</head>
<body onload="example()">
<header id="title">
Parsami tutta
</header>
<form>
</form>
</body>
</html>
【问题讨论】:
-
您确定响应是 jsonp 吗,请转到以下链接查看更多关于 jsonp stackoverflow.com/questions/2067472/what-is-jsonp-all-about 的信息。
标签: javascript jquery json parsing jsonp