ajax 表单提醒 (jQuery)
ajax form alert (jQuery)
我对 ajaxform 有疑问。
我有一个名为 captcha.php 的 php 文件,它生成一个验证码:
<?php
session_start();
$random_number = rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9);
$_SESSION['captcha_text'] = $random_number;
$captcha_image = imagecreatefromjpeg("captcha.jpg");
$font_color = imagecolorallocate($captcha_image, 0, 0, 0);
imagestring($captcha_image, 5, 20, 5, $random_number, $font_color);
imagejpeg($captcha_image);
imagedestroy($captcha_image);
?>
我有另一个名为 pro.php 的 php 文件,它在操作表单上执行并发送包含表单数据的电子邮件:
<?php
session_start();
@extract($_POST);
$sub = "Curriculum di: ".stripslashes($name);
$message = stripslashes($messaggio);
$fromail = stripslashes($email);
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: ".$fromail;
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message="This is a multi-part message in MIME format.
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
$message
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
if(isset($_POST['txtCaptcha']) and $_POST['txtCaptcha'] !='')
if($_SESSION['captcha_text'] == $_POST['txtCaptcha'])
mail('myemail@myemail.it', $sub, $message, $headers);
?>
现在我想在电子邮件发送正确与否时显示提醒:
<script>
$(document).ready(function() {
$('#myFormId').ajaxForm(function() {
//Instructions to enter
});
});
</script>
有什么解决办法? (抱歉我的英语不好)
你必须调用成功参数:
$("your-form").ajaxForm({
success: function(res, status, xhr, form) {
// ... call the alert
}
});
写得很好。
我对 ajaxform 有疑问。 我有一个名为 captcha.php 的 php 文件,它生成一个验证码:
<?php
session_start();
$random_number = rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9).rand(1,9);
$_SESSION['captcha_text'] = $random_number;
$captcha_image = imagecreatefromjpeg("captcha.jpg");
$font_color = imagecolorallocate($captcha_image, 0, 0, 0);
imagestring($captcha_image, 5, 20, 5, $random_number, $font_color);
imagejpeg($captcha_image);
imagedestroy($captcha_image);
?>
我有另一个名为 pro.php 的 php 文件,它在操作表单上执行并发送包含表单数据的电子邮件:
<?php
session_start();
@extract($_POST);
$sub = "Curriculum di: ".stripslashes($name);
$message = stripslashes($messaggio);
$fromail = stripslashes($email);
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: ".$fromail;
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message="This is a multi-part message in MIME format.
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-Type: text/plain; charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
$message
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
if(isset($_POST['txtCaptcha']) and $_POST['txtCaptcha'] !='')
if($_SESSION['captcha_text'] == $_POST['txtCaptcha'])
mail('myemail@myemail.it', $sub, $message, $headers);
?>
现在我想在电子邮件发送正确与否时显示提醒:
<script>
$(document).ready(function() {
$('#myFormId').ajaxForm(function() {
//Instructions to enter
});
});
</script>
有什么解决办法? (抱歉我的英语不好)
你必须调用成功参数:
$("your-form").ajaxForm({
success: function(res, status, xhr, form) {
// ... call the alert
}
});
写得很好。