$(function () {
$.ajax({
type: 'GET',
url: '/api',
data: {},
dataType: 'json',
beforeSend:function(xhr){
xhr.setRequestHeader("token","Basic "+"生成token值");
},
success:function (data) {
console.log(data)
if (data.err == 0) {
alert("成功");
}else {
alert("失败")
}
}
})
})
$(function () {
$.ajax({
type: 'GET',
url: '/api',
data: {},
dataType: 'json',
headers: {"token","Basic "+"生成token值"}
success:function (data) {
console.log(data)
if (data.err == 0) {
alert("成功");
}else {
alert("失败")
}
}
})
})