---
description: https://github.com/mgalante/jquery.redirect
---

# jQuery - Redirect with post, Get data php (ok)

A simple HTTP POST and GET Redirection Plugin for jQuery

* Easy to use
* GET and POST requests
* Compatible with jQuery, jQlite and Zepto.js
* Supports nested objects and arrays

**Ví dụ đã hoàn thành**

```
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
    <script type="text/javascript" src="jquery.redirect.js"></script>
</head>
<body>
    <button type="button" name="button">TEST</button>
    <script type="text/javascript">
    //Log instead of redirect for testing purposes
    jQuery(function($) {
      $("button").click(function() {
        $.redirect("http://localhost/ajaxsubmit/test.php",
        [{
          user: "johnDoe",
          password: "12345",
          submit: "name",
          phones: [
            { area: "11", number: "4444444" },
            { area: "22", number: "5555555" }
          ]
        }, 
        {
          user: "gastonJones",
          password: "5431",
          submit: "Gastón Jones",
          phones: [
            { area: "11", number: "41321" }
          ]
        }],
        "POST", null, null, true);
      });
    });
    </script>
</body>
</html>
```

C:\xampp\htdocs\ajaxsubmit\test.php

```
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <?php  
    echo "<pre>";
    var_export($_POST);
  ?>
</body>
</html>
```

![](https://2494213435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYjAG13rAPdbArSfRyB%2Fuploads%2FbGoIy8ClvrAIZ1L4opbM%2FScreenshot_1.png?alt=media\&token=73253d0e-5c68-4e3c-9b1f-42d212bc6850)

C:\xampp\htdocs\ajaxsubmit

{% file src="https://2494213435-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LYjAG13rAPdbArSfRyB%2Fuploads%2Fxobv60mSJjU3SKSDmZ9c%2Fjquery.redirect.zip?alt=media&token=f3f5f67b-90d2-408d-9d29-e6c925bb0a40" %}

