我使用Ajax提交表单。我在我的表单上使用了captcha,当我提交表单时没有任何验证错误,我第一次使用了captcha。有时服务器返回一些验证错误,并且不提交表单。此时我需要刷新验证码图像,而无需重新加载整个页面。如何重新加载表单通过Ajax提交验证码?
图形验证码中的Zend形式:
$captcha= new Zend_Form_Element_Captcha('captcha', array(
'id'=>'captcha',
'title'=>'Security Check.',
'captcha' => array(
'captcha' => 'Image',
'required' => true,
'font' => '../public/fonts/ARIALN.TTF',
'wordlen' => '6',
'width' => '200',
'height' => '50',
'imgdir' => '../public/images/captcha/',
'imgurl' => '/images/captcha/'
)));
jQuery的表单提交:
jQuery('form.AjaxForm').submit(function() {
$.ajax({
url : $(this).attr('action'),
type : $(this).attr('method'),
dataType: 'json',
data : $(this).serialize(),
success : function(data) {
// reload captcha here
alert('Success');
},
error : function(xhr, err) {
// reload captcha here
alert('Error');
}
});
return false;
});
如何重新加载表单提交验证码?
感谢
+1感谢您的回复。我正在看这个.. – Student 2012-01-31 19:26:13