passing 2 variables from jquery to php file
Posted: Fri Jun 03, 2011 9:16 am
i have syntax problem while transferring more than 2 values from jquery to php file ..but code dint work...when i try to transfer only 1 variable it works but
not with more than 1 variable....here is the codes that im using..
var data1=$("#textbox1").val(); //textbox with name textbox1 in html page
var data2=$("#textbox1").val(); //textbox with name textbox2 in html page
$.ajax({
type: "POST",
url: "insert.php",
data: { data1,data2}, //i stuck in this line
cache: false,
success: function(html){
//some codes here
},
});
in insert.php file:
if(isset($_POST['data1'])||isset($_POST['data2']))
{
echo $_POST['data1'];
echo $_POST['data2'];
}
not with more than 1 variable....here is the codes that im using..
var data1=$("#textbox1").val(); //textbox with name textbox1 in html page
var data2=$("#textbox1").val(); //textbox with name textbox2 in html page
$.ajax({
type: "POST",
url: "insert.php",
data: { data1,data2}, //i stuck in this line
cache: false,
success: function(html){
//some codes here
},
});
in insert.php file:
if(isset($_POST['data1'])||isset($_POST['data2']))
{
echo $_POST['data1'];
echo $_POST['data2'];
}