懒得多说直接上代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" value="从服务器获取数据" id="btn" />
</body>
</html>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
document.getElementById("btn").onclick = function() {
$.ajax({
type: "get",
url: "http://m2.qiushibaike.com/article/list/suggest?page=1&type=refresh&count=30&callback=jQuery11110017538199282051803_1501481265118&_=1501481265119",
dataType: 'jsonp',
async: false,
error: function() {
alert('请求超时');
},
success: function(datatext) {
var json=JSON5.parse(datatext);
alert(json.toString());
}
});
}
// var sp = document.createElement("script");
// sp.src = "http://m2.qiushibaike.com/article/list/suggest?page=1&type=refresh&count=30"
// document.body.appendChild(sp);
// }
</script>