Home > front end >  Javascript can't introduce json
Javascript can't introduce json

Time:11-21

These two methods is introduced into Json error, are in the same directory, is there a way to solve it



<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
<script SRC="https://bbs.csdn.net/topics/jquer.js" & gt; </script>
<script SRC="https://bbs.csdn.net/topics/index01.js" & gt; </script>
<link rel="stylesheet" href="https://bbs.csdn.net/topics/index.json" & gt;
Document
<style type="text/css">
</style>

<body>
<script>

//method 1
$. GetJSON (" text. Json ", function (data) {

console.log(data);

});

//method 2
$. Ajax ({
Type: "get",
Url: "text. Json,"
DataType: "json",
Success: the function (data) {
console.log(data);
},
Error: function () {
Alert (" attempt failed ");
}
});

</script>



  • Related