首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在用户身份验证中使用Ajax请求?

如何在用户身份验证中使用Ajax请求?
EN

Stack Overflow用户
提问于 2015-11-27 07:48:31
回答 1查看 52关注 0票数 0

如何使用Ajax请求与MD-5哈希算法进行用户身份验证?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-27 07:58:13

代码语言:javascript
复制
    <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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33952553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档