'); var statusdiv=$('#comment-status'); commentform.submit(function(){ //serialize and store form data in a variable var formdata=commentform.serialize(); //Add a status message statusdiv.html('


'); //Extract action URL from commentform var formurl=commentform.attr('action'); //Post Form with data $.ajax({ type: 'post', url: formurl, data: formdata, error: function(XMLHttpRequest, textStatus, errorThrown) { statusdiv.html('

You might have left one of the fields blank, or be posting too quickly

'); }, success: function(data, textStatus){ if(data == "success" || textStatus == "success"){ statusdiv.html('

Thanks for your comment. We appreciate your response.

'); }else{ statusdiv.html('

Please wait a while before posting your next comment

'); commentform.find('textarea[name=comment]').val(''); } } }); return false; }); });