title: Why my requests with http basic auth get status 0 when I set bad credentials ? Phonegap Android
body: <p>In my android app made with phonegap, users can sign in. When they do it, JQuery get their login and their password and do an ajax call with theirs credentials following the HTTP Basic Auth specification. Everything works fine.<br>
  However I'm encountering a problem for handling the situation when a user sets bad credentials. In the .error() callback, I want to display a specific message for status 401 (like "authentication failed") and another message for other status ("technical problem"). My code :</p>
  
  <pre><code>$.ajax({
                  url: "http://exemple.com",
                  type: "GET",
                  dataType: "text",
                  contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                  beforeSend: function (xhr)
                  {
                      xhr.setRequestHeader("Authorization", "Basic "+$.base64.encode(email+":"+password));
                  },
                  success: function() {
                      //my success callback
                  },
                  error: function(xhr) {
                      if(xhr.status===401) {
                          //"authentication failed"
                      }
                      else {
                          //"technical problem"
                      }
                  }
              });
  </code></pre>
  
  <p>This code works fine in browser. Status 401 is send. But when I test in my phonegap android app, the status send is 0. When my credentials are good, the status send is 200, and others requests of my app works well, so I don't think it's a cors problem.</p>
  
  <p>Any idea ? Thanks for your help</p>