AJAX:如何在另一个页面上显示数据

I have the following function below. When a button is clicked, the function below is executed. The function basically sends json data to the page "temp.php", via Ajax

I think the sending of data is successfull. My main problem is printing/displaying the data sent by ajax to the "temp.php" page.

    **Orders.php:**

    function convertToJson()
    {
        var tableData = $('#productOrder').tableToJSON({
            ignoreColumns: [0]
        }); 
        var result = JSON.stringify(tableData)
        $.ajax({
            url: "http://localhost/app/temp.php",
            data: {result},

            type: "POST",
        })
          .done(function( json ) {
                document.getElementById('testDiv').innerHTML = result;
          })

          .fail(function( xhr, status, errorThrown ) {
            alert( "Sorry, there was a problem!" );
            alert( "Error: " + errorThrown );
            alert( "Status: " + status );
            alert( xhr );
          })

          .always(function( xhr, status ) {
            alert( "The request is complete!", status );
          });           
    }

   **This is the content of "temp.php"**
   <?php
   $Id = json_decode($_POST['Id']);
   $Name = json_decode($_POST['Product Name']);
   $Unit = json_decode($_POST['Unit']);

   echo "<h1>$Id</h1>";
   ?>

   **This is the json data (var result) that is being sent by ajax**


   [{"Id":"43","Product Name":"Orchid","Unit":"Test","Rate(PHP)":"600.00","Quantity":"5.00","Sub-Total (PHP)":"3,000.00"}]

Look at the data you are sending:

data: {result},

(which is shorthand for data: {result: result},)

So your form encoded data has one key in it, result.

Now look at the PHP:

$_POST['Id']

There is no Id in the data you are sending. Only result.

$_POST['Product Name']

There is no Product Name in the data you are sending. Only result.

etc.