I have a very simple comment form, which submits through $.ajax
. However, I'm having some problems with it refreshing on submit.
This happens even though I am using both e.preventDefault()
and return false
within my submission script
.
I have looked at every single post I can find on StackOverflow and even various Fiddles, but have come across no solutions.
This is my JavaScript:
$(".f-track-actions__form").submit(function(ev){
ev.preventDefault();
var wave = $.cookie("cv"),
wave = eval(wave),
waveDuration = wave.getDuration();
var child = $(this).children(".f-track-actions__form-comment");
var cTime = (wave.getCurrentTime() / waveDuration) * 100;
var pD = {
'c': comment.val(),
'i': child.attr('id'),
't': cTime
};
$.ajax({
type: "post",
url: "/spectrum-rr/core/_func/functions/actionTrack.php",
data: pD,
success: function(data) {
alert(data);
}
});
return false;
});
HTML:
<form method="post" class="f-track-actions__form">
<input class="f-track-actions__form-comment" type="text" placeholder="Comment on this track..." name="comment" id="c-1">
</form>
Thanks.