user4fun Posted April 4, 2009 Share Posted April 4, 2009 I keep geting that eh $name is empty?register.php <script type="text/javascript">var http = false;if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP");} else { http = new XMLHttpRequest();}function validate(name){ http.open("POST", "validate_form.php", true); http.onreadystatechange=function() { if(http.readyState == 4) { document.getElementById('UsernameMsg').innerHTML = http.responseText; } } http.send(name);}</script><h1>Please choose your username:</h1><form name="signup"> <input type="text" name="name" id="name" onchange="validate(this.value)" /> <div id="UsernameMsg"></div></form> validate_form.php <?if($_POST["name"] == "") echo "name is empty";else echo "you typed ".$_POST["name"];?> No matter what I do, I alway get the output asname is emptyAlso, how would this be changed arround so I can also send out the send input box for the next validation, say I want to send the phone number value to see that the user has inputted all enough numbers.I dont want to have to make a new function and a validation page for input box. Link to comment Share on other sites More sharing options...
Synook Posted April 4, 2009 Share Posted April 4, 2009 You need to set a few additional headers when using POST with AJAX.http://www.google.com.au/search?q=AJAX+POST Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.