在 SAPUI5 中 AJAX 請求中新增身份驗證詳細資訊


基本上,你需要利用 JQuery AJAX 的 beforeSend 函式來解決你的需求。

這是一個基本的程式碼片段 -

function AddToHeader(xhr) {
    var pwd = // get the password;
    xhr.setRequestHeader("Authorization", "Basic " + btoa(user + ":" + pwd));
}
$.ajax({
   type: "GET",
   url: <method url >,
   dataType: "JSON",
   beforeSend: function(xhr) {
      AddToHeader (xhr);
   }
}).done(function(data) { /* do success logic */ }

你可以向首部新增更多詳細資訊,如 AddToHeader 方法中所述。

更新日期:12-6 月-2020

已觀看 803 次

開啟你的職業生涯

完成課程可獲取認證

開始吧
廣告
© . All rights reserved.