i'm working on a php chat and everything work good but i wanted ajax for stoping the refresh page.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#submit").on("click", function (event) {
event.preventDefault();
$.ajax({
type: "POST",
url: "index.php",
data: $("#chat").serialize(),
success: function () {
alert('lorem ipsum');
}
});
});
});
</script>
<form name="chat" action="" method="post" id="chat">
<b>Msg:</b>
<input type="text" name="msg" size="30" class="text">
<input type="submit" name="submit" value="Send!" class="bttn" id="submit">
<input type="hidden" name="lastcat" value="<?php echo $simplecat; ?>">
<input type="hidden" name="lastwas" value="<?php echo $command; ?>">
</form>
<hr>
<div class="leftalign">
<b class="yousay">You say:</b> <?php echo stripslashes($usermessage); ?><br /><br />
<b class="catsays">Cat replies:</b> <?php echo $catreply;?><br /><br />
i see the msg box and the page wont refresh but my $_POST['msg'] is empty so what i missed?