Ajax asynchronous request PHP Data _ PHP Tutorial

Source: Internet
Author: User
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 ,...

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.