I want to see if I can connect to a third site using HTTP authentication. Ideally, the browser will save the credentials. Unfortunately, this fails every time. Any help would be much appreciated, I am using j64 plugin for base64 which I tested to work.
So, two questions:
- How to view HTTP status code?
- Will this ultimately work in principle?
<script> $("#login_button").click(function() { var username = 'myFunUsername'; var password = 'myFunPassword'; $.ajax({ url: 'http://remote-site-with-http-auth.com/member_site', beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic " + $.base64.encode(username + ":" + password)); }, success: function(data) { $("#label").text("Logged in, yay!"); } }).fail(function(){ $("#label").text("It didn't work"); }); });
Thanks!!
source share