javascript - 提交问题内部服务器错误

标签 javascript jquery .net ajax regex

我尝试通过如下表单提交数据,但出现错误:

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/

相关文章:

jquery - iframe 忽略后的 HTML

c# - react 性 : Latest value to be received by IObservable

c# - 在 .NET 2.0 中将位图转换为一个多页 TIFF 图像

c# - Quartz.Net 在 ASP.Net 应用程序中

javascript - 实现这个特定布局的最佳方式是什么?

javascript - 如何将 ul 和 li 转换为 select 和 options 并保留类?

javascript - Reduce() 一个已经被减少的元素的对象

javascript - 使用组合 reducer 时无法将状态映射到 Prop

jquery - 从 iframe 打开一个模态窗口到父窗口

javascript - 为什么 validateform() 返回 false 时提交了表单?