Ajax asynchronously requests PHP Data. Ajax asynchronously requests PHP Data to a teacher's job. if the layout of the implementation is entered with the Department ID, the department name only displays the corresponding ID. If no department ID is entered, all is displayed, ajax asynchronous request for PHP Data
After receiving a assignment from the instructor, the layout is achieved.
If you enter the Department ID, only the department name corresponds to the ID is displayed. if you do not enter the Department ID, all are displayed. then, based on the value of the department name, the text box in the main section automatically displays the name of the major section. For example, if you select the cardiovascular department, the department displays the Department of Internal Medicine.
The main code is as follows:
Request department by ID
function showHint(str){ var xmlhttp; if (window.XMLHttpRequest) {// IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// IE6, IE5 xmlhttp=new ActiveXObject(Microsoft.XMLHTTP); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(txtHint).innerHTML=xmlhttp.responseText; } } xmlhttp.open(GET,keshi.php?q=+str,true); xmlhttp.send();}
Keshi. php:
'; While (!! $ RowDKQ = fetchAssoc ($ resultDKQ) {$ hint. =''; $ ResultKSQ = queryDB (select region, table_keshi.sid, table_keshi.name from table_dake, table_keshi where table_dake.name =' {$ rowDKQ ['name']} 'and table_keshi.sid = region ); while (!! $ RowKSQ = fetchAssoc ($ resultKSQ) {$ hint. =''. $ RowKSQ ['name'].'';} $ Hint. ='';}} // Not the number else {$ resultDK = queryDB (select table_dake.name from table_dake); $ hint =' department name: '; While (!! $ RowDK = fetchAssoc ($ resultDK) {$ hint. =''; $ ResultKS = queryDB (select region, table_keshi.sid, table_keshi.name from table_dake, table_keshi where table_dake.name =' {$ rowDK ['name']} 'and table_keshi.sid = region ); while (!! $ RowKS = fetchAssoc ($ resultKS) {$ hint. =''. $ RowKS ['name'].'';} $ Hint. ='';}}$ Response = $ hint; // output response echo $ response;?> Effect: No ID is entered. for example, enter the ID in: Next: Baijia search: add search engines such as Google and Baidu to the website.
Received a assignment from the instructor. if the department ID is entered, only the department name corresponding to the ID is displayed. If no department ID is entered, all is displayed ,...