I've used the GET xmlhttp request before but can't seem to get the post one to work for me. Can anyone see what I'm doing wrong?
saveTitle.php hasCode:<html> <head> <script type="text/javascript"> function saveTitle() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { alert(xmlhttp.responseText); } } var title = "title=" + document.getElementById("title").value; xmlhttp.open("POST","saveTitle.php",true); xmlhttp.send(title); } </script> </head> <body> <input name="title" id="title" onblur="saveTitle()" type="text" /> </body> </html>
Firebug shows the POST data as title=asdf but the alert coming back from the response so I think I'm calling that wrong, or the value is not being set to title as I think it is...PHP Code:<?php
echo $_POST['title'];
?>



Reply With Quote

Bookmarks