I am trying to get my comments area to post without refreshing the page using the below code but It just refreshes anyway. I have tried putting return false; everywhere but nothing. Is there an obvious problem i cant see?
$('#commentForm').keydown(function(e) { if (e.keyCode == 13) { var songComment = $("#songComment").val(); var username = $("#username").val(); var comid = $("#comid").val(); var dataString = 'songComment=' + songComment + '&username=' + username + '&comid=' + comid; if(dataString=='' || songComment=='' || username=='' || comid=='') { $('.success').fadeOut(200).hide(); $('.error').fadeOut(200).show(); } else { $.ajax ({ type: "POST", url: "comment.php", data: dataString, success: function(){ $('.success').fadeIn(200).show(); $('.error').fadeOut(200).hide(); } }); } return false; }; });