我有以下代码:
var url = "save.php"; // the script where you handle the form input.
$.ajax({
type: "POST",
url: url,
data: $("#frmSurvey").serialize(), // serializes the form's elements.
success: function(){
alert('success');
},
error: function(){
alert( "Request failed: " );
}
});
现在,这在向数据库提交数据时工作正常 - 但是,当我故意更改save.php
文件以便不提交数据时,我仍然会收到success
警报。
保存文件的代码如下:
$proc = mysqli_prepare($link, "UPDATE tresults SET ip = ?, browser = ?, q1 = ?, q2 = ?, q3 = ?, q4 = ?, q5 = ?, q6 = ?, q7 = ?, q8 = ?, q9 = ?, q10 = ?, q11 = ?, q12 = ?, q13 = ?, q14 = ?, q15 = ?, q16 = ?, q17 = ?, q18 = ?, q19 = ?, q20 = ?, q21 = ?, q22 = ?, q23 = ?, q24 = ?, q25 = ?, q26 = ?, q27 = ?, q28 = ?, q29 = ?, q30 = ?, q31 = ?, q32 = ?, q33 = ?, q34 = ?, q35 = ?, q36 = ?, q37 = ?, q38 = ?, q39 = ?, q40 = ?, q41 = ?, q42 = ?, q43 = ?, q44 = ?, q45 = ?, q46 = ?, q47 = ?, q48 = ?, q49 = ?, q50 = ?, q51 = ?, q52 = ?, q53 = ?, q54 = ?, q55 = ? WHERE respondent_id = ?;");
mysqli_stmt_bind_param($proc, "ssiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiissi", $ip, $browser, $q1, $q2, $q3, $q4, $q5, $q6, $q7, $q8, $q9, $q10, $q11, $q12, $q13, $q14, $q15, $q16, $q17, $q18, $q19, $q20, $q21, $q22, $q23, $q24, $q25, $q26, $q27, $q28, $q29, $q30, $q31, $q32, $q33, $q34, $q35, $q36, $q37, $q38, $q39, $q40, $q41, $q42, $q43, $q44, $q45, $q46, $q47, $q48, $q49, $q50, $q51, $q52, $q53, $q54, $q55, $respondent_id);
mysqli_stmt_execute($proc);
$mysql_error = mysqli_error($link);
if ($mysql_error!="") {
printf("Unexpected database error: %s\n", $mysql_error);
mysqli_stmt_close($proc);
mysqli_clean_connection($link);
exit();
} else
{
mysqli_stmt_close($proc);
mysqli_clean_connection($link);
update_completion_status($respondent_id, 'Started');
header("Location: index.php?r=".$rguid);
}
我哪里错了?