ajax
2018-07-31 本文已影响0人
试翼腾渊
data.json
{
"zhushi":"200表示请求成功",
"code":200,
"data" :{
"name":"你好卫毅鑫",
"age":19,
"imgurl":"",
"info":[
"female",
"syudent",
{
"front":["js","css","html","ps"],
"back":["python","mysql"]
}
]
},
"msg":"成功",
}
ajax.js
$.ajax({
url:"js/data.json",
type:"get",
dataType:"json",
})
.done(function(data){
if(data.code == 200){
alert("成功le")
$(".liebiao2 .dao3").html(data.data.name);
}
})
.fail(function(jqXHR,texStatus,errorThrown){
alert("链接超时");
console.log("error");
console.log(jqXHR.responseText);
console.log(jqXHR.status);
console.log(jqXHR.readState)ß
console.log(jqXHR.statusText);
console.log(texStatus);
console.log(errorThrown);
})