Call the blog for the Garden Su Hengfeng article. The first collection, in the study;
Http://www.cnblogs.com/in-loading/archive/2012/05/18/2508123.html
json.html Code
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >
<title>php JSON transfer data </title>
<script type= "Text/javascript" src= "Js/jquery.js" ></script>
<script type= "Text/javascript" >
$ (function () {
$ ("#submit"). Click (function () {
var text = $ ("input"). Serialize ();
$.ajax ({
' type ': ' POST ',
' URL ': ' json_encode.php ',
' DataType ': ' JSON ',
' Data ': text,
Success:insertdata
});
});
});
function InsertData (data) {
var str = "name =" +data.name+ "<br/> gender =" +data.sex+ "<br/> age =" +data.age;
$ ("#view"). html (str);
}
</script>
<body>
Name: <input name= "name" id= "name" type= "text" value= "" ><br/>
Gender: <input name= "Sex" id= "Sex" type= "text" value= "" ><br/>
Age: <input name= "ages" id= "aged" type= "text" value= "" >
<input type= "Submit" name= "submit" id= "Submit" value= "Submission" >
<div style= "FONT-SIZE:14PX;" id= "View" >
</div>
</body>
json_encode.php Code
<?php
Header ("Content-type:text/html;charset=utf8");
Include ("json.php");
$name = $_post[' name '];
$sex = $_post[' sex '];
$age = $_post[' age '];
$json _arg = Array (' name ' = = $name, ' sex ' = $sex, ' age ' = $age);
$json = new json;
$json _result = $json->encode ($json _arg);
echo $json _result;
?>
PHP JQUERY JSON Instance