如何使用带有MD-5哈希算法的用户身份验证的Ajax GET请求?
答案 0 :(得分:0)
<script type="text/javascript">
function sendRequest(username, password)
{
var url = "http://ajaxref.com/ch7/protectedhash.php";
var options = { method: "GET",
username : username,
password : AjaxTCR.data.encodeMD5(password),
onSuccess : showResponse,
onFail : showFail};
AjaxTCR.comm.sendRequest(url,options);
}
function showFail(response, message)
{
var responseOutput = document.getElementById("responseOutput");
responseOutput.innerHTML = "<h3>Error:</h3>" + message;
}
function showResponse(response)
{
var responseOutput = document.getElementById("responseOutput");
responseOutput.innerHTML = response.xhr.responseText;
//document.location = "http://ajaxref.com/ch7/protectedhash/myprotectedpage.php";
}
window.onload = function ()
{
document.requestForm.requestButton.onclick = function () { sendRequest(this.form.txtUser.value, this.form.txtPass.value); };
};
</scr
&#13;