Ajax plus PHP for three-level linkage

Source: Internet
Author: User

JS Code

<script type= "Text/javascript" >
function Get_next (t,pid) {//ID of current element, value of current option, usually ID? Anyway, mine is.
$.ajax ({
Type: "POST",
URL: "/index.php?type=company&m=action&a=getnext",
Data: "Pid=" +pid,
DataType: ' JSON ',
Success:function (msg) {
$ ("#" +t). Next (' SELECT '). HTML (MSG.STR);//Stitching HTML
}
});
}
</script>

PHP code

Public Function GetNext ()
{

$next = $sql//Lookup database Pid=post The ID of the SQL
$str = "<option value=" > Please select </option> ";
foreach ($next as $val) {
$str. = "<option value=". $val [' id ']. "' > ". $val [" name "]." </option> ";
}
$msg ["str"] = $STR;
echo Json_encode ($msg);
Die ();
}

Can be called anywhere, but there is a small flaw that I choose to ignore. Hee Hee

Ajax plus PHP for three-level linkage

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: info-contact@alibabacloud.com 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.