1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
function loginHint(e) {
e.preventDefault();
e.stopPropagation();
// If username field is empty, inform user and exit function
var uname = $("#login #username").val();
if(uname == "") {
alert("You have to enter a username to receive a password hint");
return;
}
// POST username to the function /ajax/pwdhint which returns a json object with password hint
$.post(
// Replace with final production URL!!!
"ajax/pwdhint",
// Data sent through POST
{ username: uname },
// Callback function
function(data) {
var result = $.parseJSON(data)["hint"];
// result["hint"] is either a boolean false or a string containing the hint
if(result === false) {
$("#hinttext").html('<p class="error">No password hint available</p>');
} else {
$("#hinttext").html('<p>Hint: ' + result + '</p>');
}
$("#login").toggleClass("expanded");
$("#hinttext").toggle();
}
); // End $.post {}
} // End loginHint()
|