2015-11-27 6 views
0

Как использовать запрос Ajax GET с пользователем Аутентификация с помощью алгоритма хеширования MD-5?Как использовать запрос Ajax с аутентификацией пользователя?

+0

Я голосую, чтобы закрыть этот вопрос не по теме, потому что он не показывает каких-либо усилий на всех. – Rob

ответ

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

+0

это то, что я сделал, но не работал? –

Смежные вопросы