I am trying to use XMLHttpRequest() to send a GET request to a web service. When I type the uri in the browser, it promotes a dialogue window that asks username and password. I'm trying to get the XMLHttpRequest() to do the samething, namely after the request, the user will see window asking for username/password.
Below is the code I have at the moment. It gets " [HTTP/1.1 401 Unauthorized]" error in the debugger instead of promoting a window asking for authentication. How should I do this? Can someone please help? Many thanks in advance!
var uri= "someuri that will promotes a dialogue window if I access it in a browser"
var xhr = new XMLHttpRequest();
xhr.open("GET",uri,true);
xhr.setRequestHeader("Accept", "application/json");
xhr.onload= function(){
//what should I do here?
}
xhr.send(null);
Aucun commentaire:
Enregistrer un commentaire