Gman7 Posted July 28, 2010 Share Posted July 28, 2010 Hello, I'm building a simple web application that involves the following function being invoked on the click of a button. function signUp(). { var username = document.getElementById('username').value; var pass = document.getElementById('password').value; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { if (xmlhttp.status==200) { document.getElementById('username').value = 'asd'; document.getElementById('password').value = ''; } } } xmlhttp.open('GET','http://127.0.0.1/bookmark/newuser.php?username='+username+'&&pass='+pass,true); xmlhttp.send(); } The request is sent to the following PHP page. <?php $uname = $_GET[username]; $pass = $_GET[pass]; $con = mysql_connect("localhost","gman","asdf"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bookmarker", $con); $sql="INSERT INTO users (username, pass) VALUES('$uname','$pass')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else { echo "BAZINGA!"; } mysql_close($con); ?> The problem I'm having is that the response status is never 200. I've checked my database, and the Users table is getting updated with the entries regularly, however, the response never arrives for some reason. Could someone please point out anything I'm doing wrong here? Thanks in advance! 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.