ホームページ  >  記事  >  バックエンド開発  >  PHP 用の AJAX

PHP 用の AJAX

WBOY
WBOYオリジナル
2016-06-23 13:39:40989ブラウズ

非同期 JavaScript と XML

AJAX サーバーはありません。

AJAX はブラウザ内で実行されるテクノロジーです。ブラウザと Web サーバーの間で非同期データ転送を使用し、Web ページがページ全体ではなく少量の情報をサーバーに要求できるようにします。

AJAX は、Web サーバー ソフトウェアから独立した Web ブラウザー テクノロジーです。


Three.

PHP で関連するプロンプトを入力する例、合計 3 つのファイル


index.php:

<html><head><script src="clienthint.js"></script> </head><body><form> First Name:<input type="text" id="txt1"onkeyup="showHint(this.value)"></form><p>Suggestions: <span id="txtHint"></span></p></body></html>

gethint.php:

<?php	// Fill up array with names$a[]="Anna";$a[]="Brittany";$a[]="Cinderella";$a[]="Diana";$a[]="Eva";$a[]="Fiona";$a[]="Gunda";$a[]="Hege";$a[]="Inga";$a[]="Johanna";$a[]="Kitty";$a[]="Linda";$a[]="Nina";$a[]="Ophelia";$a[]="Petunia";$a[]="Amanda";$a[]="Raquel";$a[]="Cindy";$a[]="Doris";$a[]="Eve";$a[]="Evita";$a[]="Sunniva";$a[]="Tove";$a[]="Unni";$a[]="Violet";$a[]="Liza";$a[]="Elizabeth";$a[]="Ellen";$a[]="Wenche";$a[]="Vicky";//get the q parameter from URL$q=$_GET["q"];//lookup all hints from array if length of q>0if (strlen($q) > 0){$hint="";for($i=0; $i<count($a); $i++)  {  if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))    {    if ($hint=="")      {      $hint=$a[$i];      }    else      {      $hint=$hint." , ".$a[$i];      }    }  }}//Set output to "no suggestion" if no hint were found//or to the correct valuesif ($hint == ""){$response="no suggestion";}else{$response=$hint;}//output the responseecho $response;?>

clienthint.js :


りー

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。