How to use the a variable that is posted from page1 to page2 from jquery.I am using the following scenario
page1.php
if ( this.checked ) {
$.ajax({
url: 'page2.php',
type: "POST",
data: ({name: 145}),
success: function(data){
//$("#result").html(data);
}
});
}
This is not working why,if i separatly opens a page2.php and wants further usage of the post data
Page2.php
<?php
$userAnswer = $_POST['name'];
if ($_POST['submit']){
echo $userAnswer;
}
?>
<form method="post" action="page2.php">
<input type="submit" value="submit" name="submit" />
</form>
if i open page2.php and presses the submit button,the posted value from page1 is not displaying
var_dump($_POST)to see the contents. If the page reloads then there's some Javascript error, try debugging it (Ctrl + Shift + J).