我尝试通过如下表单提交数据,但出现错误:
echo 'The # here does not begin a comment.'
echo The \# here does not begin a comment.
但是如果我们像下面这样提交,就不会报错:
echo The # here does not begin a comment.
echo The # here does not begin a comment.
也就是说,没有单引号和斜杠,我无法提交数据。
代码如下:
function AjaxCallOnClick(userName, email, commentText, blogID, commentHtml, onCommentEmailID) {
var parameters = "{'commentUserName':'" + userName + "','email':'" + email + "','commentText':'" + commentText + "','blogID':'" + blogID + "','commentHtml':'" + commentHtml + "','onCommentEmailID':'" + onCommentEmailID + "'}";
$.ajax({
type: "POST",
url: "<%= ResolveUrl("~/BlogService.asmx/GetShareStoryData")%>",
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("Your Comment was Saved");
var getCommentList = response.d;
var allComments = '';
$('#dvMainAndReplyCommentSection').html('');
$.each(getCommentList, function (index, comments) {
var comment = comments.HtmlComment;
allComments += comment;
});
if (allComments) {
$('#dvMainAndReplyCommentSection').html(allComments);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
},
failure: function (response) {
alert(response.responseText);
}
});
}
解决这个问题的方法是什么?
最佳答案
我尝试过这种格式 varparameters = JSON.stringify({ commentUserName: userName, email: email, commentText: commentText, blogID: blogID, commentHtml: commentHtml, onCommentEmailID: onCommentEmailID });对我来说效果很好。
关于javascript - 提交问题内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41158054/