I have a page1.php and i have a fly.php. page1.php is a simple (regular) form page, where people put info, when user submit the form.
- via ajax it loads the captcha template and ask to verify on the fly (till here is fine).
- After onFly validation, i want to allow this .submit() continue
Question: How can i after .submit() pause for validatio
n of this captcha and after validation successfull, resume the form submission (which is on hold)?
Example:
Part 1: page1.php
$(document).ready(function() { $('.callmeback').submit(function() { $.ajax({ type : "GET", url : "/include/class/fly.php", data : "a=b", async : false, beforeSend: function() { $(document.body).find('.blackwindow').remove(); $(document.body).find('.nospam').remove(); }, complete: function() { }, success : function(msg) { $(document.body).append(msg); $('.blackwindow').css({ 'opacity':'0.90' }); $('.nospam').find('input[type="button"]').live("click", function() { // final validation var security= $('.nospam').find('#security').val(); var random = $('.nospam').find('#random').val(); if (random!=security) { alert ('Invalid captcha.'); return false; } else { // Basically its second time? and return true? } }); } }); //return false; }); });
Part 2: fly.php
require_once 'obj.php';?> .blackwindow { position:fixed; top:0px; left:0px; width:100%; height:100%; z-index:1000; background-color:#000000; } .nospam { position:fixed; top:30%; left:30%; padding:12px; border:solid 3px #686868; background-color:#ffffff; z-index:1001; } $value = obj::getRandom(); echo '
'; echo ""; ?> *Please enter the above code below, to verify this request
Follow up (proof read):
$(document).ready(function() { $('.callmeback').find('input[type="button"]').live("click", function() { $.ajax({ type : "GET", url : "/include/class/fly.php", data : "a=b", async : false, beforeSend: function() { $(document.body).find('.blackwindow').remove(); $(document.body).find('.nospam').remove(); }, complete: function() { }, success : function(msg) { $(document.body).append(msg); $('.blackwindow').css({ 'opacity':'0.90' }); $('.nospam').find('input[type="button"]').live("click", function() { // final validation var security= $('.nospam').find('#security').val(); var random = $('.nospam').find('#random').val(); if (random!=security) { alert ('Invalid captcha.'); return false; } else { $('.callmeback').submit(); } }); } }); //return false; }); });