下面的朋友是我的代码,我在线setRequestHeaders
上收到错误$(document).ready(function(){
$('#delete').click(function(){
xmlhttp = new XMLHttpRequest();
xmlhttp.open("DELETE","https://server/v0/DTDG78/Test/Tulips.jpg",true);
xmlhttp.setRequestHeader("X-Auth-Token:", "AUTH_tkba87f3f9d9be428898ba362477d18");
xmlhttp.send();
});
});
控制台上的错误消息是
组件返回失败代码:0x80004005(NS_ERROR_FAILURE)[nsIXMLHttpRequest.setRequestHeader] [打破此错误]
... lhttp.setRequestHeader( 'X-AUTH-令牌:', “AUTH_tkba87f3f9d9be428898ba362477d18 ...
我缺少什么,或者根本不可能?任何评论,建议代码表示赞赏。感谢
答案 0 :(得分:3)
如果您正在使用jQuery,为什么不让它为您处理AJAX调用?
$.ajax({
url: 'https://server/v0/DTDG78/Test/Tulips.jpg',
type: 'DELETE',
async: true,
beforeSend: function( xhr) {
// Note: You probably do not need 'X-Auth-Token:', I've removed the colon
xhr.setRequestHeader("X-Auth-Token", "AUTH_tkba87f3f9d9be428898ba362477d18");
},
success: function( result) {
// TODO
}
});