i want to send variable from one php page to another using jquery ajax
venkatesh. The question was asked: Apr 13, 2020. 08:33
1 answer
Page 1 js:
$(document).ready(function () { $(".btn").on("click", function () { $.ajax({ type: "GET", url: "./page.php", data: { name: "peter" }, success: function (data) { alert(data); }, }); }); });
Page 2 php:
<?php if(isset($_GET['name'])){ $name =$_GET['name']; echo $name; } else{ echo "data not recived"; } ?>
Here, at the first page it triggers the alert and displays the value of "name" but it doesn't return the value to the destination url and it executes the else statement. Thanks for your help!