The HTML is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> Background Management System login </TITLE>
<meta http-equiv=content-type content= "text/html; Charset=utf-8 ">
<script src= "/docs/js/jquery-1.8.1.min.js" ></script>
</HEAD>
<body>
Name: <input type= "text" name= "name" id= "name" value= "Tom"/><br/>
Age:<input type= "text" name= "Age" id= "age" value= "all"/><br/>
<textarea name= "Contents" id= "Contents" ></textarea><br/>
<a href= "#" onclick= "Javascript:tijiao ();" > Submit </a>
<div style= "height:100px;width:500px;border:1px solid red;" id= "shows" ></div>
</BODY>
</HTML>
<script>
function Tijiao ()
{
$.ajax ({
Type: "POST",
ContentType: "Application/json",
URL: '/test1.php ',//Jump to action
Data: ' {' ' name ': ' ' +$ (' #name '). Val () + ' "," Age ":" ' +$ (' #age '). Val () + ' "," Contents ":" ' +$ (' #contents '). Val () + ' "} ',
DataType: ' JSON ',
Success:function (Result) {
$ ("#shows"). HTML (result.name + "|") +result.age + "|" + result.contents);
}
});
}
</script>
Php:
<?php
$string = file_get_contents ("Php://input");
$res = Json_decode ($string, true);
echo Json_encode ($res);
?>
Submitted in Application/json and then used in PHP to read the raw data stream in the way obtained in Json_encode