How does php get json strings sent by ajax? ?


Front end:

 url: url ,
 method: 'post' ,
 contentType: 'application/json' ,
 data: JSON.stringify({
 name: 'test'


print_r($_REQUEST);  // []
 print_r($_POST);  // []
 print_r($_GET);  // []
 print_r(file_get_contents('php://input'));  // {"name": "test"}

Was it sentjsonString can only pass throughphp://inputThis way to obtain? What are the advantages of data interaction between front and back ends in this way? ?

contentType: ‘application/x-www-form-urlencoded’