给出了我的代码的以下摘要:
JS
$(function() {
$(".submit").click(function() {
var dataString = 'user=' + user + '&size=' + size + '&q_1=' + q_1 + '&q_2=' + q_2 + '&q_3=' + q_3 + '&q_4=' + q_4 + '&q_5=' + q_5;
$.ajax({
type: "POST",
url: "form_send.php",
data: dataString,
success: function() {
//success
},
error: function() {
//error
}
});
return false;
});
});
PHP
if ($_POST) {
$user = $_POST['user'];
$size = $_POST['size'];
$q1 = $_POST['q_1'];
$q2 = $_POST['q_2'];
$q3 = $_POST['q_3'];
$q4 = $_POST['q_4'];
$q5 = $_POST['q_5'];
//insert data
$insert = mysql_query("INSERT INTO table (username, size, q_1, q_2, q_3, q_4, q_5) VALUES ('$user', '$size', '$q1', '$q2', '$q3', '$q4', '$q5')");
if(!$insert){ die("There's little problem: ".mysql_error());}
}
其他代码经过检查并且工作正常,所以这个摘要肯定有错误;我也找不到。
它总是进入 ajax 请求的“错误”。在此先感谢您的帮助!