在 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 方法中,按說明向標題新增更多內容。

更新於: 2020年6月12日

803 瀏覽量

開啟您的 職業生涯

透過完成課程獲得認證

開始吧
廣告
© . All rights reserved.