请帮助我发现问题。尝试使用ajax发送评论时出现意外标识符 代码:
function funcSuccess (data) {
$("#comment_ajax").text(data);
}
function funcBefore (){
$("#comment_ajax").text("Loading comment...");
}
$(document).ready(function(){
$("#make_comment").bind("click", function () {
event.preventDefault();
$.ajax({
let post = $("#c_post_id").val();
let user = $("#c_user_id").val();
let text = $("#c_text").val();
url: "write_comment.php",
type: "POST",
data: {c_post_id: post, c_user_id:user, c_text:text},
dataType: "html",
beforeSend: funcBefore,
success: funcSuccess
});
});
});
它显示在“ let post = $(“#c_post_id”)。val();”行中我做错了什么?
答案 0 :(得分:0)
将代码更改为此,在您的ajax调用中将=
替换为:
,并将;
替换为,
。
function funcSuccess (data) {
$("#comment_ajax").text(data);
}
function funcBefore (){
$("#comment_ajax").text("Loading comment...");
}
$(document).ready(function(){
$("#make_comment").bind("click", function () {
event.preventDefault();
$.ajax({
post: $("#c_post_id").val(),
user: $("#c_user_id").val(),
text: $("#c_text").val(),
url: "write_comment.php",
type: "POST",
data: {c_post_id: post, c_user_id:user, c_text:text},
dataType: "html",
beforeSend: funcBefore,
success: funcSuccess
});
});
});