亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

AJAX XML

AJAX? ???? XML ??? ????? ??? ? ????.

AJAX XML ?

?? ?? ? ???? AJAX? ?? XML ???? ??? ?? ??? ?????.

?

CD? ?????.??????????????????????????????????????????????????????????????????????????????????>????????????????????????????????????????????????????????????????????????????????????????????????-?? ???? "showCD()"?? ??? ?????. ? ??? "onchange" ???? ?? ??????.

   <html>
        <head>
        <script>
        function showCD(str)
        {
            if (str=="")
            {
                document.getElementById("txtHint").innerHTML="";
                return;
            }
            if (window.XMLHttpRequest)
            {
                // IE7+, Firefox, Chrome, Opera, Safari 瀏覽器執(zhí)行
                xmlhttp=new XMLHttpRequest();
            }
            else
            {
                // IE6, IE5 瀏覽器執(zhí)行
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                }
            }
            xmlhttp.open("GET","getcd.php?q="+str,true);
            xmlhttp.send();
        }
        </script>
        </head>
        <body>
        <form>
        Select a CD:
        <select name="cds" onchange="showCD(this.value)">
        <option value="">Select a CD:</option>
        <option value="Bob Dylan">Bob Dylan</option>
        <option value="Bonnie Tyler">Bonnie Tyler</option>
        <option value="Dolly Parton">Dolly Parton</option>
        </select>
        </form>
        <div id="txtHint"><b>CD info will be listed here...</b></div>
        </body>
     </html>

showCD() ??? ?? ??? ?????.

1) CD? ?????? ??

2) XMLHttpRequest ?? ??

3) ?? ??? ???? ???? ?? ??

4) ??? ??? ?? ???

5) ?? ?? URL ?? ??? ????(q ) (???? ??? ?? ??)

??:

? ???? JavaScript ??? ?? ???????. ? ?? ?? ?????: JavaScript Tutorial


PHP ??

??? JavaScript? ?? ???? ?? ???? "getcd.php"?? ??? PHP ?????. .

PHP ????? XML ?? "cd_catalog.xml"? ???? XML ??? ?? ??? ??? ? ??? HTML? ?????.

<?php
$q=$_GET["q"];
$xmlDoc = new DOMDocument();
$xmlDoc->load("cd_catalog.xml");
$x=$xmlDoc->getElementsByTagName('ARTIST');
for ($i=0; $i<=$x->length-1; $i++)
{
// 處理元素節(jié)點
if ($x->item($i)->nodeType==1)
{
if ($x->item($i)->childNodes->item(0)->nodeValue == $q)
{
$y=($x->item($i)->parentNode);
}
}
}
$cd=($y->childNodes);
for ($i=0;$i<$cd->length;$i++)
{ 
// 處理元素節(jié)點
if ($cd->item($i)->nodeType==1)
{
echo("<b>" . $cd->item($i)->nodeName . ":</b> ");
echo($cd->item($i)->childNodes->item(0)->nodeValue);
echo("<br>");
}
}
?>

CD ??? ??? ?? ?? JavaScript?? PHP ???? ???? ??:

1. PHP? XML DOM ??? ?????.

2. JavaScript? ??? ???

3. ?? ??? ???? "txtHint" ?? ???? ?? ????.

??: xml ?? ??

??:

XML? ?? ??? ?????.

???? ??? ???? ???? ?? ???? ??? ??? ???????. ??? ??? ????? DOM? ?????.

??:

??? ???? ???? ?? ??? ??? ?? ??? ???? ??? ???? ???. ?? ??? ??? ?? responseXML ?? ?? ????.

????? ? XML ??? ???? DOM ?? ??? ???? ? ????.

???? ??
||
<?php //需要與前面的HTML文件聯(lián)合使用 $q=$_GET["q"]; $xmlDoc = new DOMDocument(); $xmlDoc->load("cd_catalog.xml"); $x=$xmlDoc->getElementsByTagName('ARTIST'); for ($i=0; $i<=$x->length-1; $i++) { // 處理元素節(jié)點 if ($x->item($i)->nodeType==1) { if ($x->item($i)->childNodes->item(0)->nodeValue == $q) { $y=($x->item($i)->parentNode); } } } $cd=($y->childNodes); for ($i=0;$i<$cd->length;$i++) { // 處理元素節(jié)點 if ($cd->item($i)->nodeType==1) { echo("<b>" . $cd->item($i)->nodeName . ":</b> "); echo($cd->item($i)->childNodes->item(0)->nodeValue); echo("<br>"); } } ?>