I want to pass data from one page to another page. I tried below code. The result\_display.php always gave me an empty array of \_POST. I'd appreciate it if someone can point me where is wrong. Thanks.

index.php

```
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>js save session</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<input type="submit" id="mybutton" value="My Button">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script>
    $(document).ready(function () {

        $("#mybutton").click(function () {

            $.ajax({
                method: "POST",
                url: "./result_display.php",
                data: {name: "John", location: "Boston"}
            })
                .done(function (msg) {
                    console.log("Data Saved: " + msg);
                });

            window.location.href = "result_display.php";
        });
    });
</script>
</body>
</html>

```

result\_display.php

```
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
?>

<?php
    var_dump($_POST);
?>

```