Using Ajax with JQuery is easy and good for the validation as well as animation in your website.
just see a Basic code to understand these all together...
code....
<html>
<head>
<title>Basic Ajax</title>
</head>
<body>
<form id="userform">
<p><input type="text" name="name" id="name"></p>
<p><input type="password" name="password" id="password"></p>
<input type="submit" name="submit" value="Submit">
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "></script>
<p id="para"></p>
<script type="text/javascript">
$(document).ready(function(){
$("#userform").submit(function(e){
e.preventDefault();
var name = $("#name").val();
var password = $("#password").val();
$.ajax({
url:"now.php",
type:"POST",
data:{name: name,password:password},
success:function(data){
$("#para").html(data);
}
})
});
})
</script>
</body>
</html>
Now.php file code.......
<?php
$name = $_POST['name'];
$password = $_POST['password'];
echo $name." -> ".$password;
?>
If you have any query Comment below .... Thank you😋
just see a Basic code to understand these all together...
code....
<html>
<head>
<title>Basic Ajax</title>
</head>
<body>
<form id="userform">
<p><input type="text" name="name" id="name"></p>
<p><input type="password" name="password" id="password"></p>
<input type="submit" name="submit" value="Submit">
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "></script>
<p id="para"></p>
<script type="text/javascript">
$(document).ready(function(){
$("#userform").submit(function(e){
e.preventDefault();
var name = $("#name").val();
var password = $("#password").val();
$.ajax({
url:"now.php",
type:"POST",
data:{name: name,password:password},
success:function(data){
$("#para").html(data);
}
})
});
})
</script>
</body>
</html>
Now.php file code.......
<?php
$name = $_POST['name'];
$password = $_POST['password'];
echo $name." -> ".$password;
?>
If you have any query Comment below .... Thank you😋
Awesome code
ReplyDeleteHmmm nice one
ReplyDelete