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
  • 25,247
  • 27
  • 110
  • 174
Stephen
  • 2,238
  • 3
  • 28
  • 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
  • 13,169
  • 38
  • 56