Jquery Ajax Post Json

var markers = { "markers": [
  { "position": "128.3657142857143", "markerPosition": "7" },
  { "position": "235.1944023323615", "markerPosition": "19" },
  { "position": "42.5978231292517", "markerPosition": "-3" }
]};
$.ajax({
    type: "POST",
    url: "post.php",
    data: JSON.stringify(markers),
    contentType: "application/json; charset=utf-8",
    dataType: "text",
    success: function(data){alert(data);},
    failure: function(errMsg) {
        alert(errMsg);
    }
});

请求头

PHP

<?php
$data = file_get_contents("php://input");
echo $data;

原始JSON串

原文地址:https://www.cnblogs.com/phpfans/p/3320639.html