繁体   English   中英

提交问题内部服务器错误

[英]Submission issue internal server error

我正在尝试通过以下表格提交数据,这会导致错误:

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);
            }
        });

    }

解决该问题的方法是什么?

我尝试过这种格式的var参数= JSON.stringify({commentUserName:userName,email:email,commentText:commentText,blogID:blogID,commentHtml:commentHtml,onCommentEmailID:onCommentEmailID}); 对我来说很好。

尝试...在保存对象时删除双引号。

function AjaxCallOnClick(userName, email, commentText, blogID, commentHtml, onCommentEmailID) {

var parameters = JSON.stringify({'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 res=JSON.parse(response);
            var getCommentList = res.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) {
            var res=JSON.parse(response);
            alert(res.responseText);
        }
    });

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM