Reputation: 1864
hi guys below is my code and i am getting error on line 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();
});
});
The Error message on console is
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.setRequestHeader] [Break On This Error]
...lhttp.setRequestHeader('X-Auth-Token:', 'AUTH_tkba87f3f9d9be428898ba362477d18...
What am i missing or it is not possible at all ? any comments , suggestions code is appreciated. thanks
Upvotes: 0
Views: 3825
Reputation: 59709
If you're using jQuery, why not let it handle the AJAX call for you?
$.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
}
});
Upvotes: 3