Make a POST request using AJAX doesn't work
<p>I've a pure javascript code and I need to send a JSON (that could be big so exceed the GET limit ....), so I'd like to use AJAX for the POST request.</p>

<p>My code is ...</p>

<pre><code>    &lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;title&gt;Test POST via AJAX&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        var waypoints = [{
                "options": {
                    "allowUTurn": false
                },
                "latLng": {
                    "lat": 44.911434,
                    "lng": 7.671602
                },
                "name": "Corso Vinovo, Carignano, TO, Piemonte, Italia",
                "_initHooksCalled": true
              }, {
                "options": {
                    "allowUTurn": false
                },
                "latLng": {
                    "lat": 44.910167,
                    "lng": 7.676274
                },
                "name": "Il Tempio del Pane, Corso Cesare Battisti, Carignano, TO, Piemonte, Italia",
                "_initHooksCalled": true
              }, {
                "options": {
                    "allowUTurn": false
                },
                "latLng": {
                    "lat": 44.908034,
                    "lng": 7.675075
                },
                "name": "Banca Intesa, Via Ferdinando Salotto, Carignano, TO, Piemonte, Italia",
                "_initHooksCalled": true
        }];

        alert ('Waypoints --&gt; ' + JSON.stringify(waypoints));

        $.ajax({
          type: "POST",
          url: "NewPage.php",
          contentType: "application/json",
          data: JSON.stringify(waypoints),
          success: function()
           {
            alert("OK ...");
           },
          error: function()
           {
             alert("KO ...")
           }
        })

       alert('After post request ...');

    &lt;/script&gt;
   &lt;/body&gt;
  &lt;/html&gt;
</code></pre>

<p>and here you're the code of NewPage.php</p>

<pre><code>&lt;?php
    echo 'Waypoints ?????';
    print_r($_POST)
?&gt;
</code></pre>

<p>Executing the code I can see that my AJAX code alert me "OK", but I can't see anything about my NewPage.php</p>

<p>I'm quite a newbye about this stuff, so sorry for banality ....</p>

<p>Any suggestions, example, jsfiddle, alternative?</p>

<p>Thanks a lot in advance!</p>

<p>Cesare</p>