我的示例代码在此处托管:
<html>
<head>
<title>Untitled Page</title>
<script type="text/javascript" src="/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$.ajax({
type: "GET",
url: "http://your-ser.com/reports.json",
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "haha",
success: function(json){
alert('------'+json.name);
},
error: function(){
alert('fail');
}
});
});
</script>
</head>
<body>
</body>
</html>
服务器端json看起来像:
{"name": "peter","age": "100","id":"001"}
jQuery是v2.1.3,我试过chrome 43 / firefox,都得到了“失败”警报,有人可以帮忙查看原因吗?