ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


[Ajax] ajax ¿¹Á¦1
9³â Àü
test1.php

<form>
First Name : <input type="text" id="txt1" onkeyup="showHint(this.value)">
</form>
<p>Suggestions : <span id="txtHint"></span></p>


<script>

function showHint(str)
{

        if(str.length==0)
        {
                document.getElementById("txtHint").innerHTML="";
                return;
        }

        xmlHttp = GetXmlHttpObject();
        if(xmlHttp==null)
        {
                alert ("Your browser does not support AJAX!");
                return;
        }

        var url="time.php";
        url=url+"?q="+str;
        url=url+"&sid="+Math.random();
        xmlHttp.onreadystatechange=stateChanged;
        xmlHttp.open("GET",url,true);
        //# true ÀÌ¸é ºñµ¿±â½Ä ó¸®, send() ¸Þ¼Òµå ½ÇÇà½Ã ¼­¹ö¿¡ ¿äûÈÄ ¼­¹öÀÇ ÀÀ´äÀ»
        //# ±â´Ù¸®Áö ¾Ê°í ¹Ù·Î ´ÙÀ½ ÀÚ¹Ù½ºÅ©¸³Æ® ½ÇÇàµÊ
        xmlHttp.send(null);
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
}
catch (e)
{
  // Internet Explorer
  try
  {
   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
   xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
}
return xmlHttp;
}


function stateChanged()
{
        if (xmlHttp.readyState==4)
        {
                document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
        }
}


</script>

time.php

<?php
header("Cache-Control: no-cache, must-revalidate");
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// 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>0

if (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 values
if ($hint == "")
{
        $response="no suggestion";
}
else
{
        $response=$hint;
}
//output the response
echo $response;
?>
ÃßõÃßõ : 336 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
2,705
jQuery.getJSON, JSON µ¥ÀÌÅ͸¦ ·Îµå
2,704
jQuery length¿Í slideToggle ¿¹Á¦
2,703
[CSS] before¿Í after ¼±ÅÃÀÚ¸¦ ÀÌ¿ëÇÏ¿© Float ¼Ó¼º ÇØÁ¦
2,702
jQuery toggleClass() Methods
2,701
jQuery stop(),Callback,Chaining
2,700
jQuery Effects - Animation
2,699
jQuery Effects - Sliding
2,698
jQuery fadeIn(), fadeOut(), fadeToggle(), fadeTo()
2,697
jQuery hide(), show(), toggle()
2,696
jquery trigger(), ÇÔ¼ö ½ÇÇà½ÃÅ°±â
2,695
ºñ¹Ð¹øÈ£(Æнº¿öµå) À¯È¿¼º üũ (¹®ÀÚ, ¼ýÀÚ, Ư¼ö¹®ÀÚÀÇ Á¶ÇÕÀ¸·Î 6~16ÀÚ¸®)
2,694
PHP ¹®ÀÚ¿­¿¡ ÇѱÛÀÌ Æ÷ÇԵǾî ÀÖ´ÂÁö üũ
2,693
ÇѱÛüũ(preg match)
2,692
javascript escape/unescape -> php
2,691
Æú´õ¾ÈÀÇ ÆÄÀÏ °¡Áö°í ³î±â
2,690
Á¤±Ô Ç¥Çö½ÄÀ¸·Î ÇÑ±Û ¹®ÀÚ Æ÷ÇÔÇÏ´ÂÁö È®ÀÎÇϱâ
2,689
À¯´ÏÄڵ带 ÀÌ¿ë ÇÑ±Û Ãʼº, Áß¼º, Á¾¼ºÀ¸·Î ÂÉ°³±â - ÇѱÛ/¿µ¹® º¯È¯
2,688
ÇÑ±Û Ãʼº,Áß¼º,Á¾¼º ÀÚ¸£±â ÇÔ¼ö
2,687
ÆÄÀ̽㿡¼­ À¯´ÏÄÚµå ½ºÆ®¸² ´Ù·ç±â
2,686
Python 2.x ÇÑ±Û ÀÎÄÚµù °ü·Ã Á¤¸®
2,685
%uABCD%u1234 °°Àº urlÀÇ À¯´ÏÄÚµå µðÄÚµù
2,684
ÇѱÛ, ÇÑÀÚ¸¦ À¯´ÏÄÚµå·Î º¯È¯Çϱâ
2,683
°æ·Î ºÐ¸®Çϱâ
2,682
ÇÑ±Û ASCII Äڵ带 À¥ URL¿¡¼­ »ç¿ëµÇ´Â UTF8 ÄÚµå·Î º¯È¯
2,681
Unicode (UTF-8) ÀÎÄÚµù¿¡¼­ ÇÑ±Û ±ÛÀÚ¼ö Ãâ·Â ¹× iconv substr
2,680
PHP¿¡¼­ À¯´ÏÄÚµå·Î ¹®ÀÚ¿­ ÀÎÄÚµùÇϱâ
2,679
[JavaScript] µÚ·Î°¡±â È÷½ºÅ丮°¡ ¾ø´Â °ÍÀ» ¾î¶»°Ô ¾Ë ¼ö ÀÖÀ»±î?
2,678
htmlspecialchars, entity decode
2,677
Php : Finding Chrome and Safari Browsers
2,676
[Shoutcast] jPlayer and Shoutcast Configuration
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.