JQuery.ajax setRequestHeader 添加Authorization

 1 $.ajax({
 2     type: "GET",
 3     url: "test.php",
 4     success: function(data) {
 5         console.log(data);
 6     },
 7     beforeSend: function(xhr) {
 8        token = window.localStorage.getItem('token');
 9             xhr.setRequestHeader("Authorization", "Bearer" + token);
10     }
11 });

 

posted @ 2018-12-20 14:22  MollyHan  阅读(1945)  评论(0)    收藏  举报