POST方法不显示,但GET方法

My POST method does not display on the webpage, but my GET method does even though I haven't create a method with it in my global.js. Does the GET method come with POST? I want my POST to display not GET. How do I do that? I know that my POST work i think because in network (that is in the browser with console), the POST method is there, and the preview prints out the $_POST and $_SESSION. How do I make POST to display on the page instead of GET.

Button.php

<!doctype html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">                </script>
    <script src ="global.js"></script>
    <title>Button POST</title>
  </head>
  <body>
       <button id ="postbutton" onclick="location.href='storage.php'">GO</button><br>
  </body>
</html>

storage.php

<?php
print_r($_POST);
if(isset($_POST['json'])){
  $_SESSION['object'] = $_POST["json"]; 
  print_r($_SESSION);
  echo 'True';
}else {
  echo 'False';
}

global.js

var oject = [{name:'John', age:17},{name:'James', age:22}];
var json = JSON.stringify(oject);


$(document).ready(function(){
  $('#postbutton').click(function(){
    $('#output').html('sending..');
      var jobject = JSON.stringify(oject);
      console.log(jobject);
      $.ajax({
        method:'post',
        url:'storage.php',
        data:{json:oject},
      })
      .done(function(data){
        console.log(data);
    });
  });
});

Your GET method is work because you used onclick with location.href method .That will always redirected with GET method so it can display your output ! But to work with POST method in ajax you need to remove onclick method and append return data to body element .

Button.php

<!doctype html>
  <html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">                </script>
    <script src ="global.js"></script>
    <title>Button POST</title>
  </head>
  <body>
       <button id ="postbutton">GO</button><br>
  </body>
</html>

global.js

var oject = [{name:'John', age:17},{name:'James', age:22}];
var json = JSON.stringify(oject);


$(document).ready(function(){
  $('#postbutton').click(function(){
    $('#output').html('sending..');
      var jobject = JSON.stringify(oject);
      console.log(jobject);
      $.ajax({
        method:'post',
        url:'storage.php',
        data:{json:oject},
      })
      .done(function(data){
       $("body").append(data);
    });
  });
});

Why there's a onclick in button which you happen you call $.ajax() at the same time:

<button id ="postbutton" onclick="location.href='storage.php'">GO</button><br>

If you want to use $.ajax() no need for onclick. You can call location.href indside done(function(data) {}) if it met your conditions and you want to redirect the user somewhere else.