Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JQuery for basic authentication random behavior?
- function make_basic_auth(un, pss)
- {
- var tok = un + ':' + pss;
- var hash = Base64.encode(tok);
- return "Basic " + hash;
- }
- $('#loginform').submit(function()
- {
- var username = $('.username').val();
- var password = $('.passcode').val();
- $.ajax({
- type: 'POST',
- url: 'serverIP/loginService',
- contentType: "application/json",
- **async: false**,
- beforeSend: function(xhr)
- {
- var auth = make_basic_auth(username, password);
- xhr.setRequestHeader('Authorization', auth);
- },
- success: function (xhr, status){
- alert(status);
- },
- error: function (xhr, status){
- alert(status);
- }
- });
- });
Add Comment
Please, Sign In to add comment