我现在正在尝试几个小时,无法让它工作
我的ajax调用
$('.button').click( function() {
var mail = $("#mail_content").val();
alert(mail);
$.ajax({
type: "POST",
url: "process.php",
data: "mail="+ mail,
success: function(){
alert("success");
}
});
});
我的 process.php
<?php
// echo "<pre>";
// print_r($_POST);
// echo "</pre>";
include 'config.php';
include 'lib.php';
$db = dbConnect();
$mail = quote_smart($_POST['mail']);
//insert, update, select, delete
$query = "INSERT INTO mail VALUES ('', '$mail')";
$result = insertQuery($query);
dbClose($db);
echo "entry saved";
?>
我的表格
<div class="email">
<div class="email_title">GET NOTIFIED FOR THE GRAND OPENING<br /> </div>
<div id="contact_form">
<form id="mail" name="mail" action="" method="post" enctype="multipart/form-data">
<fieldset>
<label for="mail" id="email_label">YOUR EMAIL</label>
<input type="text" name="mail_content" id="mail_content" size="30" value="" class="text-input" />
<input type="submit" name="submit" class="button" id="submit_btn" value="SAVE" />
</fieldset>
</form>
</div>
</div>
我在忽略什么吗?当我将 process.php 代码放在表单中的操作中时它可以工作