Part 6 Practical 3: Write a JQuery code to send login information to the web server using AJAX and process the response.
ScreenShots
1
2
3
4
5
Concept Used In This Practical :
In 1st picture there is a sign in form which was created using form tag.
In 2nd picture there is a some code written in php language basically we create an array
which contains some usernames....suppose that this value came from the database.
In 3rd Picture we fill the username and it will display the message without refreshing page
"username exists".This will happen because of ajax.
similarly, In 4th picture again we try to insert another username but unfortunately this will
also present in the database so again message was printed after the input element.
In last picture we seen that we successfully created account...
Sample code :
function valuname(str){
var req=new XMLHttpRequest();
req.open("get","http://localhost/ajax/username.php? uname="+str,true);
req.send();
req.onreadystatechange=function(){
if(req.readyState==4 && req.status==200){
document.getElementById("sp").innerHTML=req.responseText;
document.getElementById("sp").style.color="white";
}
}
}
In 1st picture there is a sign in form which was created using form tag.
In 2nd picture there is a some code written in php language basically we create an array
which contains some usernames....suppose that this value came from the database.
In 3rd Picture we fill the username and it will display the message without refreshing page
"username exists".This will happen because of ajax.
similarly, In 4th picture again we try to insert another username but unfortunately this will
also present in the database so again message was printed after the input element.
In last picture we seen that we successfully created account...
Sample code :
function valuname(str){
var req=new XMLHttpRequest();
req.open("get","http://localhost/ajax/username.php? uname="+str,true);
req.send();
req.onreadystatechange=function(){
if(req.readyState==4 && req.status==200){
document.getElementById("sp").innerHTML=req.responseText;
document.getElementById("sp").style.color="white";
}
}
}