jQuery('document').ready(function($){ // Get the comment form var commentform=$('#commentform'); // Add a Comment Status message commentform.prepend('
'); // Defining the Status message element var statusdiv=$('#comment-status'); commentform.submit(function(){ // Serialize and store form data var formdata=commentform.serialize(); //Add a status message statusdiv.html('

'+ translation.s1 +'

'); //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){ if (errorThrown == 'Too Many Requests') { statusdiv.html('

'+ translation.s2 +'

'); } }, success: function(data, textStatus){ var regExp = /

ERROR<\/strong>: (.*?)<\/p><\/p>/; var matches = regExp.exec(data); if (matches) { statusdiv.html('

'+matches[1]+'

'); } else { statusdiv.html('

'+ translation.s3 +'

'); setTimeout( function() { location.reload(true); }, 3000); } } }); return false; }); });