Created
May 20, 2011 19:15
-
-
Save pdeschen/983569 to your computer and use it in GitHub Desktop.
Ajax jQuery Authentication Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax( { | |
url : '/model/user.json', | |
dataType : 'json', | |
beforeSend : function(xhr) { | |
var bytes = Crypto.charenc.Binary.stringToBytes(username + ":" + password); | |
var base64 = Crypto.util.bytesToBase64(bytes); | |
xhr.setRequestHeader("Authorization", "Basic " + base64); | |
}, | |
error : function(xhr, ajaxOptions, thrownError) { | |
reset(); | |
onError('Invalid username or password. Please try again.'); | |
$('#loginform #user_login').focus(); | |
}, | |
success : function(model) { | |
cookies(); | |
... | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
basic authentication not working..//