다이제스트 인증을 사용하여 유효성을 검사해야하는 양식이 있습니다. 나는 여전히 인증 작업을하고 있지만 기본적인 HTML 폼이있다. 양식 확인 JQuery .submit()
<form method="post" id="loginForm" class="validate">
<div data-role="fieldcontain">
<label for="password">Email:</label>
<input class="required email" type="text" name="username" id="username" placeholder="[email protected]">
</div>
<div data-role="fieldcontain">
<label for="password">Password:</label>
<input class="required" type="password" name="password" id="password" placeholder="password">
</div>
<input type="submit" value="Login">
</form>
은 또한 방법 그러나, .submit가 호출되지 않는
$('#loginForm').submit(function() {
alert('click');
username = $('#username').value();
password = $('#password').value();
realm = tokens['realm'];
nonce = tokens['nonce'];
qop = tokens['qop'];
alert('submitted');
ha1 = bcrypt(username + ":" + realm + ":" + password);
ha2 = bcrypt("GET:" + "http://localhost:8090/web/login");
response = bcrypt(ha1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" ha2);
$.ajax(
type: 'GET', // maybe POST?
url: url,
complete: function(xhr, status) {
if (status == 200) {
// success. save the nonce and nc in the local storage.
// whenever you send a request to the server, use the nonce
// and nc
alert('Success');
}
else {
// failure, try again
alert('Failure');
}
}
)
});
와 JS 외장라는 파일 digest_auth.js 있습니다. 처음에는 알림()을 추가했지만 아무 것도 얻지 못했습니다. 나는
<script type="text/javascript" src="digest_auth.js"></script>
이 자바 스크립트가 DOM 후로드 http://jsfiddle.net/MxgEf/7/은 (body 태그에있는 스크립트)? 그렇지 않다면'$ (function() {... 여기에 코드 ..}); jquery closuer (onready function) – bokonic
어떻게 ajax를위한 "url"을 만들고 있습니까? – ATOzTOA