$.ajax({
"url":"http://localhost:9999/getToken",
"method":"POST",
"async":false,
"content-type":"multipart/form-data",
"data":"",
"success":function(response){
console.log(response);
apt.setRequestHeader("Authorization", response.access_token);
}
});
响应结果 response.access_token 为 NaN
$.ajax({
"url":"http://localhost:9999/getToken",
"method":"POST",
"async":false,
"content-type":"multipart/form-data",
"data":"",
"success":function(response){
console.log(response);
response = typeof response == 'object' ? JSON.parse(response) : response; // 加上这行
apt.setRequestHeader("Authorization", response.access_token);
}
});
还是不行,这个响应本来就是json格式,他无法解析响应内的属性,我用的V6.0.2
辛苦您添加一下QQ:1352772403,我们技术远程协助您一起解决一下
解决了
var tokenType = JSON.parse(response).token_type;
var token = JSON.parse(response).access_token;
console.log(response);
apt.setRequestHeader("Authorization", tokenType+token);
这个样子就行了
参数冲突了吧,response 在全局变量中被使用了。