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]; } ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.