The AJAX JSON type returns

Source: Internet
Author: User

Text styles and drop-down styles

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http:// ">$ (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 (; }                        })                })            $("#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>&nbsp;<span> Name:" +data[1]                + "</span>&nbsp;<span> Gender:" +data[2]                + "</span>&nbsp;<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 Code

The AJAX JSON type returns

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.