我正在使用来自https://github.com/posabsolute/jQuery-Validation-Engine的
验证起作用了,但是AJAX没有起作用...问题是它对我来说很多次都不起作用,我试着做了30多次都失败了,我不知道为什么,他的AJAX提交php例子对我没有用……
下面是我用来验证表单的脚本:
$("#formID").validationEngine({promptPosition : "centerRight", scroll: false, ajaxFormValidation: true});下面是我想要与验证引擎集成的jQuery AJAX脚本:
$.ajax({
type: "POST",
url: "send.php",
data: sendData,
beforeSend: function () {
$("#ajax").show();
},
success: function () {
$('#listo').html("<p>Thank you!</p>")
.hide()
.fadeIn(1000, function () {
});
}
}); 还有另一个用来发送数据表单的PHP脚本:
function send_email() {
$message = "\nNombre: " . $_POST['nombre'] .
"\nEmail: " . $_POST['email'] .
"\nMensaje: " . $_POST['message'] .
"\nTélefono: " . $_POST['tel'];
$message .= "\n\nBrowser Info: " . $_SERVER["HTTP_USER_AGENT"] .
"\nIP: " . $_SERVER["REMOTE_ADDR"] .
"\n\nDate: " . date("Y-m-d h:i:s");
$siteEmail = 'my@mail.com';
$emailTitle = 'Contact from your website';
$thankYouMessage = "succesful sent.";
if(! mail($siteEmail, $emailTitle, $message, 'From: ' . $_POST['nombre'] . ' <' . $_POST['email'] . '>'))
echo 'cannot send...';}
有人能帮我吗?
发布于 2011-10-27 04:50:03
你能试试这个吗:
jQuery(document).ready(function () {
jQuery("#formID").validationEngine({
promptPosition: "centerRight",
scroll: false,
ajaxFormValidation: true,
ajaxFormValidationURL: "send.php",
onBeforeAjaxFormValidation: function () {
$("#ajax").show();
},
onAjaxFormComplete: function () {
$('#listo').html("<p>Thank you!</p>")
.hide()
.fadeIn(1000);
}
});
});https://stackoverflow.com/questions/7907882
复制相似问题