I am trying to create a basic authentication through the browser, but I can't really get there.(我正在尝试通过浏览器创建基本身份验证,但我真的无法到达那里。)
If this script won't be here the browser authentication will take over, but I want to tell the browser that the user is about to make the authentication.(如果此脚本不在此处,则浏览器身份验证将接管,但是我想告诉浏览器用户即将进行身份验证。)
The address should be something like:(地址应类似于:)
http://username:[email protected]/
I have a form:(我有一个表格:)
<form name="cookieform" id="login" method="post">
<input type="text" name="username" id="username" class="text"/>
<input type="password" name="password" id="password" class="text"/>
<input type="submit" name="sub" value="Submit" class="page"/>
</form>
And a script:(和一个脚本:)
var username = $("input#username").val();
var password = $("input#password").val();
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = Base64.encode(tok);
return "Basic " + hash;
}
$.ajax
({
type: "GET",
url: "index1.php",
dataType: 'json',
async: false,
data: '{"username": "' + username + '", "password" : "' + password + '"}',
success: function (){
alert('Thanks for your comment!');
}
});
ask by Patrioticcow translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…