How does php get json strings sent by ajax? ?

  question

Front end:

$.ajax({
 url: url ,
 method: 'post' ,
 contentType: 'application/json' ,
 data: JSON.stringify({
 name: 'test'
 })
 });

Server:

print_r($_REQUEST);  // []
 print_r($_POST);  // []
 print_r($_GET);  // []
 
 //Finally!
 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’