我使用以下方法發出 AJAX 請求:function getJSON(url, callback) { var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "json"; xhr.onload = function() { if (xhr.status === 200) { callback(null, xhr.response); } else { /*var errorObj = { status: xhr.status, statusText: xhr.statusText }; callback(errorObj, xhr.response);*/ callback(xhr.status, xhr.response); } }; xhr.send();};如果狀態為 403.xhr.response為空,我必須從服務器獲取自定義響應文本,盡管我可以在 Chromium 調試器窗口的網絡選項卡中看到自定義錯誤消息。如何訪問自定義響應文本?
如何在 HTTP 403 響應中獲取自定義錯誤響應文本
智慧大石
2021-10-14 15:46:45