Main Page code
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title> <Scriptsrc=".. /wenjian/jquery-2.2.3.min.js "></Script></Head><Body><SelectID= "Sheng"> <option>Please select</option></Select><SelectID= "Shi"> <option>Please select</option></Select><SelectID= "Qu"> <option>Please select</option></Select></Body></HTML><Script>$.ajax ({data: {parent_id:0}, //the data sentDataType:"JSON", //the type of the return value text is string typeType:'Post', //method of sending the request (get)URL:'sheng_l.php',//send the requested addressSuccess:function(data) {//callback function when sending successfully //console.log (data); for (varIinchdata) { $("#sheng"). Append ("<option value= '"+data[i][2] +"' >" +data[i][1] +"</option>")}}) $ (document). Ready (function () { $("#sheng"). Change (function () { $("#shi"). Get (0). Options.length= 1;//$ ("#qu"). Get (0). options.length= 1; varData= $("#sheng"). Find ("option:selected"). Val (); $.ajax ({data:{parent_id:data}, type:"Post", DataType:"JSON", URL:"sheng_l.php", Success:function(data) { for(varIinchdata) { $("#shi"). Append ("<option value= '" +data[i][2] +"' >" +data[i][1] +"</option>")}})}) $ (document). Ready (function () { $("#shi"). Change (function () { $("#qu"). Get (0). Options.length= 1; varData= $("#shi"). Find ("option:selected"). Val (); $.ajax ({data:{parent_id:data}, type:"Post", DataType:"JSON", URL:"sheng_l.php", Success:function(data) { for (varIinchdata) { $("#qu"). Append ("<option value= '" +data[i][2] +"' >" +data[i][1] +"</option>") } } }) }) })
Working with page codes
<? PHP /* */require_once ". /wenjian/dbda.class.php "; $db New Dbda (); $sql = "SELECT * from region WHERE father_id = {$_post[' parent_id ']}"; $result $db->query ($sql); echo json_encode ($result);
Ajax three-level linkage notation