I'm developing a simple website. When the user opens my website, I hope to kind of redirect him to a REST endpoint that somebody else wrote, and log in there, and get the json result data from that REST API. If I open the endpoint directly from my browser, it would pop up a dialog box asking for username & password. After I enter and log in, a json string would show up saying that I logged in successfully.
This is my code
$.ajax({
url: "http://ift.tt/2a80c9Y",
type: "get",
cache: true,
crossDomain: true,
success: function(data, textStatus) {
alert("success " + data);
},
error: function(data, textStatus) {
alert("error " + data);
}
})
I was originally having CORS issue but that has been fixed. Now when I open my index page, it will "redirect" me to the authentication url, and the same dialog box would pop up. But after I fill in my username and password, it always returns 401 authentication failed error. If I then copy the url to a new tab in my browser, it's showing the correct json string. That means my login is correct.f016 /devsandbox/sdlpl/fliu/fliu_sdlpl/ntsdlpl/3.0/packages/Admin/Web/python/sdlw
Looks like my ajax request does not have my login info cached, or somehow does not log in. Does anyone have an idea what I did wrong and how I can fix it?
Thanks!!
Aucun commentaire:
Enregistrer un commentaire