Contoh Kode AJAX lengkap |
gethp.php header('content-type:text/xml'); mysql_connect("localhost","root","root"); mysql_select_db("a210705938"); $kode=$_GET['kode']; $qry=mysql_query("select*from bk_ujian_hp where kd_hp='$kode'"); $data=mysql_fetch_array($qry); echo" "; ?> //--------------------------------------------------- Potongan file dari Index.php function gethp(kode) { var xmlhttp; try { // ngecek buat browser firefox, opera 8.0+, safari xmlhttp=new XMLHttpRequest(); } catch (e) { // browser Internet Explorer try { // IE 6.0+ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { // IE 5.0 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("maaf browset not support ajax"); return false; } } } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { var xmldoc=xmlhttp.responseXML; document.form1.txtnamaproduk.value=xmldoc.getElementsByTagName("nama")[0].childNodes[0].nodeValue; document.form1.txtharga.value=xmldoc.getElementsByTagName("harga")[0].childNodes[0].nodeValue; } } xmlhttp.open("GET","gethp.php?kode="+kode,true); xmlhttp.send(null); } |
Jumat, 28 Januari 2011
Contoh Kode Ajax Lengkap
16.51
alie
No comments
0 komentar:
Posting Komentar