2016-12-15 2 views
0

問題内部サーバーエラーがエラー与える:提出は、私がどの以下のようにフォームを介してデータを提出しようとしています

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

    } 

このため周りの仕事は何ですか?

+0

オブジェクト 'パラメータ'を定義するのに '' "は必要ありません。 –

+0

しかし、現在、このタイプのテキストをフィールドに入れていますが、スラッシュはどうですか?それも受け入れていない。 – Vikash

+0

以下のコードを試しましたか? –

答えて

0

お試しください...オブジェクトを保存するときに二重引用符を削除します。 ({:ユーザ名、電子メール:電子メール、commentText:commentText、のblogid:のblogid、commentHtml:commentHtml、onCommentEmailID:commentUserName onCommentEmailID})私はこのフォーマットVARパラメータ= JSON.stringifyよう試み

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

} 
+0

私は以下のコードを試してみましたが、シンプルテキストでは内部サーバーエラーが発生しています。 – Vikash

+0

成功セクションにはJSON.parse関数を使用する必要があります。私の以前のパラメータ構造の単純なテキストは機能しています。 – Vikash

+0

あなたの 'response'がjson形式であれば' JSON.parse() 'を使う必要があります。両方でチェックしようとしてください。 –

0

。それは私のためにうまくいきます。

関連する問題