$(document).ready(function() {
$("form.ajax").submit(function(e) {
destString = $(this).attr('action');
dataString = $(this).serialize();
$.ajax({
type: "POST",
url: destString,
data: dataString,
datatype: json,
success: function(data) {
if (!data.success)
{
$.amwnd({
title: 'Error!',
content: data.message,
buttons: ['ok'],
closer: 'ok'
});
}
}
});
e.preventDefault();
return false;
});
});
That is some code I am using for making all forms I have with class="ajax"
submit using Ajax. I have looked at some StackOverflow questions such as this one along with other sites on the web, which has led me put this block of code in:
e.preventDefault();
return false;
That's two things that apparently both stop the form submission via normal methods, but looks like that's not working.
The form I am testing with this is
<form action="add_comment.php" method="post" class="ajax">
Am I doing something wrong, or..?