Text styles and drop-down styles
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">$ (document). Ready (function(e) {$ ("#btn"). Click (function(){ varcode=$ ("#code"). Val (); $.ajax ({URL:"Ajax3chuli.php", Data:{code:code}, type:"POST", DataType:"JSON", Success:function(data) {$ ("#name"). Text (data.name); } }) }) $("#sel"). Change (function(){ varcode=$ ( This). Val (); $.ajax ({URL:"Ajax3achuli.php", Data:{code:code}, type:"POST", DataType:"JSON", Success:function(data) {varStr= "<span> Code:" +data[0] + "</span> <span> Name:" +data[1] + "</span> <span> Gender:" +data[2] + "</span> <span> Birthday:" +data[4] + "</span>"; $("#xinxi"). html (str); } }) }) });</script>View Code<? php$code=$_post["code"];include ("dbda.class.php"), $db=new Dbda (); $sql = "SELECT name from info where code= ' {$code} '"; $attr= $db, Query ($sql); // make an associative array $arr =Array (), $arr ["name"]= $attr [0][0]; // Convert an array to JSON data Echo json_encode ($arr);
View Code<? php$code=$_post["code"];include ("dbda.class.php"), $db=new Dbda (); $sql = "SELECT * from info where code= ' {$code} '"; $attr= $db,Query ($sql); Echo Json_encode ($attr [0 ]);
View CodeThe AJAX JSON type returns