0

I'm trying to send out the pwd & username to server to verify, using a POST method. I'm currently running on localhost

Here's my code:

$.ajax('/auth/', {
        type: 'POST',
        success: function(response) {
            console.log("post success!");
        },
        headers: {'Authorization': 'Basic ' + window.btoa(username+":"+pwd_SHA1)},
        error: function(jq, textStatus, errorThrown) {
            console.log("post error");
        }
    });

The following are printed on the console:

OPTIONS /auth/
post error 

With the call stack printed.

The server did not receive the request at all, thus errorThrown is empty string.

What is wrong here?

Boyang
  • 2,520
  • 5
  • 31
  • 49
  • 2
    it is hard to figure out the problem with only this much amount of info. try using a tool like fiddler to diagnose the exact problem. or check wether you are receiving the request server side and what error status code the server is returning – Parv Sharma Sep 13 '13 at 11:23
  • Start by logging `errorThrown`. – Oskar Hane Sep 13 '13 at 11:31
  • I checked. The server did not receive the request at all – Boyang Sep 13 '13 at 11:31
  • @OskarHane errorThrown is empty string because the server never received the request – Boyang Sep 13 '13 at 11:32
  • @CharlesW. have you tried `beforeSend` instead to add your header? See here http://stackoverflow.com/questions/3258645/pass-request-headers-in-a-jquery-ajax-get-call – Oskar Hane Sep 13 '13 at 11:36
  • @OskarHane hmmm... just tried to set the header in beforeSend. didn't work – Boyang Sep 13 '13 at 11:41
  • Why don’t you pass `username` and `password` in the `settings` parameter as described in the docs? – CBroe Sep 13 '13 at 11:47

1 Answers1

0

Okay I figured out why...

In my apache site setting I have AllowOverride none. Therefore the .htaccess file is getting ignored. Thus the request can't be directed to the correct .php file.

Sorry I couldn't provide relevant info in my original question. Thanks for helping

Boyang
  • 2,520
  • 5
  • 31
  • 49