<script src= "Sanji.js" ></script>
<body>
Sanji.js
Ajax synchronization, which means that when Ajax processes data, it must wait until processing is complete to execute the statement,
Ajax asynchronous, asynchronous refers to when the AJAX processing data, not wait until the processing, the following statement can be executed
Non-Ajax
Synchronization in the exchange of information, you must wait for the other party to confirm the receipt after the next message is sent
Asynchronously when exchanging information, just send it to each other, regardless of whether the other party has no reply
On the thread
Synchronization is equivalent to single-threaded processing of one request
Asynchronously equals multi-threaded processing of multiple requests simultaneously
$ (document). Ready (function(e) {//in Div three pull down early$ ("#sanji"). HTML ("<select id= ' sheng ' ></select><select id= ' shi ' ></select><select id= ' qu ' ></select> ');//Populating DataFillsheng ();//populating the province's dataFillshi ();//populating the city's dataFillqu ();//data for populated areas//ways to fill the provincefunctionFillsheng () {varCode = "0001";//Province's parent code//call Ajax to query the province's data$.ajax ({
Async:false,//asynchronous Ajax into synchronous Ajaxurl:"Chuli.php", Data:{code:code},type:"POST", datatype:"TEXT", Success:function() {//split string, returns an array of rows
var hang = data.split ("|");
var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");
str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Put all the option in the Save Drop list
$ ("#sheng"). html (str);
}
});}
function Fillshi ()
{
var code =$ ("#sheng"). Val (); City's parent code//Call Ajax query the province's data $.ajax ({
Async:false,url: "chuli.php", Data:{code:code},type: "POST", datatype: "TEXT", Success:function() {// Splits a string, returns an array of rows
var hang = data.split ("|");
var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");
str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Place all option in the City drop-down list
$ ("#shi"). html (str);
}
});
}
function Fillqu ()
{
var code =$ ("#shi"). Val (); The parent code of the zone//call the Ajax query for the province's data $.ajax ({
Async:false,url: "chuli.php", Data:{code:code},type: "POST", DataType: "TEXT", Success:function () {//split string, returns an array of rows
var hang = data.split ("|");
var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");
str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Place all option in the City drop-down list
$ ("#qu"). html (str);
}
});
}
When the selection of the province changes, to change the city and the district
$ ("#sheng"). Change (function () {
Fillshi ();
Fillqu ();
})
Change the area when the city's selection changes
$ ("#shi"). Change (function () {
Fillqu ();
})
});
chuli.php
<? PHP include "dbda.php"; $db New Dbda (); $pcode $_post ["Code"]; $sql = "Select Areacode,areaname from chinastates where Parentareacode = ' {$pcode} '"; Echo $db->strquery ($sql);
PHP language-three-level linkage