How to send the value and request data to other page in ajax and jquery

HTML, PHP 0 Comments
tutorial-for-ajax-php

How to define the variable in ajax and jquery step by step.How to pass the multiple values through ajax jquery MySQL PHP and apply the multiple conditions in ajax and jquery  in PHP and how to implement the ajax and jquery  in PHP.How to send the value one file to another file by ID and class

 

Syntex of variable in ajax and jquery in PHP

var emailid = $(“#emailid”).val();

Daily Visit GK on myshort.in

#emailid : ID

.emailid : Class also used.

var emailid : Any name used in emailid such as email, mail etc because this is a variable.

 

Send and pass the value one file to another file  through POST and GET function with  the URL show in the given program

$.post(“action.php”,{email: emailid  },function(data){ })

 

 

Exaple of define the variable in ajax and jquery in php

<script type = “text/javascript” >

$(document).ready(function(){

$(“#sub”).click(function() {

var emailid = $(“#emailid”).val();   // defined the variable in jquery

$.post(“action.php”,{email: emailid  },function(data){

//  meaning of this line is now we are pass 3rd  parameter and send the value to next page in the form of post “,{email: emailid  }, you can any name used to ‘email ‘ because it is variable

$(“#result”).html(data);

});

});

});

</script>

—————————–

Full program 

Index.php it is main page

<html>

<head>

<title>The jQuery Example</title>

<script type = “text/javascript” src = “https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js”></script>

<script type = “text/javascript” >

//            Jquery synatx

$(document).ready(function(){

$(“#sub”).click(function() {

var emailid = $(“#emailid”).val();

 

$.post(“action.php”,{email:emailid},function(data){

 

$(“#result”).html(data);

});

});

});

</script>

</head>

<body>

<div class=”container”>

<div class=”main”>

<form  method=”POST” name=”form” action=””>

<input type=”text” name=”emailid” value=”” id=”emailid”/> <br />

<input type=”button” value=”submit” name=”sub” id=”sub”/>

</form>

</div>

<div id=”result” ></div>

</div>

</body>

</html>

 

2nd  page is action.php

<?php

echo $_POST[’email’];

?>

 

Click and Download the program code file 

 

 

share..Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0