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

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

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>

C:\xampp\htdocs\ajaxsubmit

Last updated