如何将Ajax get请求与用户身份验证结合使用?
如何使用带有MD-5哈希算法的用户身份验证的Ajax GET请求?如何将Ajax get请求与用户身份验证结合使用?,ajax,Ajax,如何使用带有MD-5哈希算法的用户身份验证的Ajax GET请求? 函数sendRequest(用户名、密码) { 变量url=”http://ajaxref.com/ch7/protectedhash.php"; var options={method:“GET”, 用户名:用户名, 密码:AjaxTCR.data.encodeMD5(密码), onSuccess:showResponse, onFail:showFail}; AjaxTCR.comm.sendRequest(url、选项)
函数sendRequest(用户名、密码)
{
变量url=”http://ajaxref.com/ch7/protectedhash.php";
var options={method:“GET”,
用户名:用户名,
密码:AjaxTCR.data.encodeMD5(密码),
onSuccess:showResponse,
onFail:showFail};
AjaxTCR.comm.sendRequest(url、选项);
}
功能显示失败(响应、消息)
{
var responseOutput=document.getElementById(“responseOutput”);
responseOutput.innerHTML=“错误:”+消息;
}
函数showResponse(响应)
{
var responseOutput=document.getElementById(“responseOutput”);
responseOutput.innerHTML=response.xhr.responseText;
//document.location=”http://ajaxref.com/ch7/protectedhash/myprotectedpage.php";
}
window.onload=函数()
{
document.requestForm.requestButton.onclick=函数(){sendRequest(this.form.txtUser.value,this.form.txtPass.value);};
};
我投票结束这个问题,因为它根本没有表现出任何努力。