這兩個方法引入Json都會報錯,都是在同一目錄下,有什么辦法解決嗎
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://bbs.csdn.net/topics/jquer.js"></script>
<script src="https://bbs.csdn.net/topics/index01.js"></script>
<link rel="stylesheet" href="https://bbs.csdn.net/topics/index.json">
<title>Document</title>
<style type="text/css">
</style>
</head>
<body>
<script>
//方法1
$.getJSON("text.json", function(data){
console.log(data);
});
//方法2
$.ajax({
type:"get",
url: "text.json",
dataType:"json",
success:function(data) {
console.log(data);
},
error:function() {
alert("請求失敗");
}
});
</script>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/225769.html
標籤:JavaScript
上一篇:微信問卷調查小程式
