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


[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 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
228
»ç¿ëÀÚ°¡ À¥ºê¶ó¿ìÀú¿¡¼­ µÚ·Î°¡±â¸¦ ÇßÀ»¶§ °¨ÁöÇÏ´Â ¹æ¹ý
227
border-radius ¼Ó¼º
226
jquery·Î °¡·Î ³ÐÀÌ(width), ¼¼·Î ³ôÀÌ(height) ÀÚµ¿ Á¶Àý
225
iframe ³ôÀÌ jquery·Î ÀÚµ¿Á¶ÀýÇϱâ
224
jquery¿¡¼­ Å×À̺í ¦¼ö, Ȧ¼ö ¹ø° TR ¹è°æ»ö º¯°æÇϱâ
223
ÀÚ¹Ù½ºÅ©¸³Æ®·Î º¹»çÇϱ⠱â´É ±¸ÇöÇϱâ
222
DIV ¿µ¿ªÀÇ À§Ä¡ ÁöÁ¤ÇÏ´Â ¹æ¹ý°ú ½ºÅ©·Ñ - Àý´ëÀ§Ä¡(absolute), »ó´ëÀ§Ä¡(relative), °íÁ¤À§Ä¡(fixed)
221
ÁÖ¼Òµî ÀÎÄÚµùÇؼ­ º¸³»±â
220
jquery load() ¸Þ¼Òµå (ºñµ¿±â À¥ÆäÀÌÁö ·Îµå)
219
[Ajax] ajax ¿¹Á¦2
[Ajax] ajax ¿¹Á¦1
217
[Ajax] JSON (Javascript Object Notation) »ç¿ëÇϱâ
216
[jQuery] jQuery.ajax() HTTP ºñµ¿±â µ¥ÀÌÅÍ ±³È¯
215
·¹ÀÌ¾î »ó´Ü ¹«Á¶°Ç°íÁ¤
214
input, select ¹Ú½º disable ½ÃÅ°±â
213
·¹À̾îÆ˾÷
212
display ¼Ó¼º, position ¼Ó¼º
211
HTML & CSS Tip
210
div display ¼Ó¼º
209
div Áٹٲްú ÁÙ¹Ù²Þ ¹æÁö
208
float:left¸¦ ´ëüÇÒ ¼ö ÀÖ´Â display:inline, inline-block
207
À¥Ç¥ÁØ TABLE (Å×À̺í)
206
dl dt dd ¿¡ ´ëÇØ
205
div ¼¼·ÎÁ¤·Ä
204
´ÙÁßÄ«Å×°í¸®
203
´ÙÁß ¼¿·ºÆ®
202
ÅؽºÆ® ¹Ú½ºÀÇ ÀԷ±ÛÀÚ¼ö Á¦ÇÑ
201
Æ˾÷âÀ¸·Î Æû°ª Àü¼ÛÇϱâ
200
¿À¸¥ÂÊ ¸¶¿ì½º Ŭ¸¯½Ã ³ªÅ¸³ª´Â ¸Þ´º
199
Å×À̺í Á¡¼±Å׵θ® ¸¸µé±â
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.