function SendComment(sender, blogId) { // first do validation var name = $("input#name" + blogId).val(); if (name == "") { $("label#name_error" + blogId).show(); $("input#name" + blogId).focus(); alert("name is missing"); return false; } var main = $("textarea#main" + blogId).val(); if (main == "") { $("label#main_error" + blogId).show(); $("textarea#main" + blogId).focus(); return false; } var email = $("input#email" + blogId).val(); var uurl = $("input#uurl" + blogId).val(); var blogId = $("input#id" + blogId).val(); var captchaCode = $('#captchacode' + blogId).val(); //then do captca check var string = "captchacode=" + captchaCode; $.ajax({ type: "POST", url: "captchaCheck.asp", data: string, cache: false, success: function() { var commentData = 'name=' + name + '&email=' + email + '&uurl=' + uurl + '&main=' + main + '&id=' + blogId; // and then send the form $.ajax({ type: "GET", url: "commentInsert.asp", data: commentData, cache: false, contentType: "application/x-www-form-urlencoded;charset=ISO-8859-1", success: function(html) { showCommentMessageBar(blogId, 'box-success-small', 'your comment has been posted.
click here to view your comment'); return false; }, error: function(xhr, status, error) { showCommentMessageBar(blogId, 'box-error-small', 'an ajax error inserting comment'); RefreshImage('imgCaptcha'); } }); RefreshImage('imgCaptcha'); ClearUserInput(blogId); }, error: function(xhr, ajaxOptions, thrownError) { RefreshImage('imgCaptcha'); showCommentMessageBar(blogId, 'box-error-small', 'The characters do not match those in the image'); return false; } }); }