I am trying to submit this form without refreshing the page. I'm using jquery; upon submit the page still refreshes.
$(function(){ $('#submit').click(function(){ $('#container').append('loading'); var sthis = $('#sthis').val(); $.ajax({ url: 'f.php' , type: 'POST', data: 'sthis: ' + sthis, success: function(result){ $('#container').append('<p>' + result + '</p>') } }); return false; }); }); html page (f.php)
<div id="container"> <form method="post" action="f.php"> something<input name="sthis" type="text" /> <input type="submit" value="submit" id="#submit" /> </form> </div> php page
<?php if(isset($_POST['sthis'])){ $sthis = $_POST['sthis']; if(empty($sthis)) { echo 'put something in this box'; } else echo 'ready'; } ?>