I have a very simple form for updating a user's status message. The form does work, but I am not getting any response (using firebug the response after submit is empty).
Here is the html/js:
<form id="StatusUpdateForm" method="post" action="http://www.url.com/process.php">
<input name="StatusUpdate" type="text" id="StatusUpdate" />
<input type="hidden" name="userid" value="<?=$_SESSION['user']['id']?>" />
<input type="submit" value="Update your status" />
</form>
<div id="results"></div>
<script>
/* attach a submit handler to the form */
$("#StatusUpdateForm").submit(function(event) {
/* stop form from submitting normally */
event.preventDefault();
/* get some values from elements on the page: */
var $form = $( this ),
StatusUpdate = $form.find( 'input[name="StatusUpdate"]' ).val(),
userid = $form.find( 'input[name="userid"]' ).val(),
url = $form.attr( 'action' );
/* Send the data using post and put the results in a div */
$.post( url , $("#StatusUpdateForm").serialize(),
function( data ) {
$('#results').html(data);
}
);
});
</script>
Here is process.php:
if($_POST['StatusUpdate']&&$_POST['userid']){
if( StatusMessage::set($_POST['userid'], $_POST['StatusUpdate']) ){
echo "<div id='content'>Comment updated!</div>";
} else {
echo "<div id='content'>Problem updating comment. Try again.</div>";
}
}