js代码:
$.ajax({
url:"js/orderMeal.json",
type:"get",
dataType:"json",
async:true,
data:{},
error:function(){
console.log("对不起,请求出错!");
},
success:function(data){
console.log(data);
}
})
json代码:
{
"firstName": "Brett",
"lastName":"McLaughlin",
"email": "aaaa"
}
然后控制台只打印出“对不起,请求出错!”,Network preview 里面可以看到json
哪位大神指点指点,不胜感激!!!
https://blog.csdn.net/qq_39206806/article/details/80940579
https://www.cnblogs.com/xdp-gacl/p/3484633.html
你得加参数 才能知道报什么错
$.ajax({
url:"js/orderMeal.json",
type:"get",
dataType:"json",
async:true,
data:{},
error:function(msg){
console.log(msg);
},
success:function(data){
console.log(data);
}
})