我正在尝试将 ajax 表单提交添加到我正在使用 jquery 开发的 PHP Web 应用程序中。表单正在提交并写入数据库,但它仍然会通过刷新完成所有操作。
这是我的代码:
$("form#form_customer").submit(function() {
var customer123first_name = $('input[name=customer123first_name.]');
var customer123last_name = $('input[name=customer123last_name.]');
var customer123date_of_birth = $('input[name=customer123date_of_birth.]');
var customer123email_address = $('input[name=customer123email_address.]');
var customer123telephone_number = $('input[name=customer123telephone_number.]');
var customer123picture = $('input[name=customer123picture.]');
var customer123id_picture = $('input[name=customer123id_picture.]');
var customer123id_expiration = $('input[name=customer123id_expiration.]');
var data = 'customer123first_name=' + customer123first_name.val() + '&customer123last_name=' + customer123last_name.val() + '&customer123date_of_birth=' + customer123date_of_birth.val() + '&customer123email_address=' + customer123email_address.val() + '&customer123telephone_number=' + customer123telephone_number.val() + '&customer123picture=' + customer123picture.val() + '&customer123id_picture=' + customer123id_picture.val() + '&customer123id_expiration=' + customer123id_expiration.val();
$.ajax({
url: "inc/createObject.php",
type: "POST",
data: data,
cache: false,
success: function(data){
$('form_success').fadeIn();
}
});
return false;
});
我在网上阅读的有关此特定问题的所有内容都发现该return false;
呼叫位于错误的位置或根本不存在。我已经检查过我的位置是否正确,但我找不到它令人耳目一新的原因。
我知道 jquery 正在工作,因为我使用它来执行运行良好的弹出窗口。
如果您想在上下文中查看代码,请访问 www.sfyfe.com/studioadmin