4

When I work from home, URLs to our development servers require basic authentication. So, if a web page has a script or link tag reference to our development server, we get a prompt for each of those server URLs.

Recently, I wrote an ajax call to an API on the development server using jQuery $.ajax. I do not get the authentication prompt, and Firebug reports 401 unauthorized. However, if I put this API directly in the browser address bar, I get the prompt.

Currently, I have to switch to Chrome and invoke --disable-web-security. When I do that, the $.ajax call will cause the browser to give me a prompt.

Is this a "problem" with $.ajax() or the browser or something else?

Liam
  • 22,818
  • 25
  • 93
  • 157
Stephen
  • 1,983
  • 2
  • 24
  • 53

1 Answers1

1

You could send your credentials along with the request as suggested in the docs of jQuery.ajax():

$.ajax({
    // ...
    username: "foo",
    password: "bar"
});

make sure you're not pushing your personal credential to some SCM, though!

rodneyrehm
  • 12,971
  • 37
  • 56