alin19 Posted August 7, 2008 Share Posted August 7, 2008 i'm trying to learn a little ajax from a book, and i have a write a code exactly like it says in my book; but the result isn't what i need, there is a javascript function that is not executed. can you take a look around <html> <head> <script language="javascript" type="text/javascript"> <!-- var cerere; function obtineNumar(prieten){ if (prieten=="") return; var url="numere.php?nume="+prieten; var nodNumar = document.getElementById('numar'); nodNumar.setAttribute('value','Caut..'); } function trateazaCererea() { if (cerere.readyState==4) { if (cerere.status==200) { raspuns = cerere.responseText; var nodNumar = document.getElementById('numar'); nodNumar.setAttribute('value',raspuns); } else { alert ("datele nu pot ficautate" +cerere.statusText); } } } --> </script> </head> <body> <form name="numere"> <table> <tr> <td>Prieten</td> <td><input type="text" size="20" maxlength="30" id="prieten" name="prieten" onchange="obtineNumar(this.value);" /></td></tr> <tr><td>Numar de tel</td> <td><input type="text" size="20" id="numar" name="numar" /> </td></tr> </table> </form> </body> </html> <?php $conexiune=mysql_connect("localhost","root","tractor") or die("conexiunea nu a putut fi realizata"); mysql_select_db("xml",$conexiune) or die ("accesul la baza de date nu a putut fi realizat"); $nume=$_GET['nume']; $interogare="select `numarr` from `numere` where `nume`='$nume'"; $rezultat=mysql_query($interogare); if (mysql_num_rows($rezultat) !=1) echo "nu exista"; else { $rez=mysql_fetch_row($rezultat); echo $rez[0]; } ?> Link to comment https://forums.phpfreaks.com/topic/118610-learning-ajax/ Share on other sites More sharing options...
corbin Posted August 9, 2008 Share Posted August 9, 2008 You never make an AJAX object or anything. If that's straight from the book, you either need to go back a couple pages, or burn that book. Just google for a simple AJAX example. Link to comment https://forums.phpfreaks.com/topic/118610-learning-ajax/#findComment-612188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.