2017-10-04 2 views
0

jsonrpcエンドポイントにデータを送信する請求書作成フォームを作成しています。サーバーはステータスコード200を返しますが、私はこの応答を取得{メッセージ: "エラーを構文解析を無効JSONは、サーバーが受信しました。"、コード:-32700、..} エラー-32700でフォームデータをjsponrpcエンドポイントに投稿する

$(document).on("submit", "#billing", function(event) 
 
{ 
 
    event.preventDefault();   
 
    $.ajax({ 
 
     url: $(this).attr("action"), 
 
     type: $(this).attr("method"), 
 
     dataType: "JSON", 
 
     data: {new FormData(this)}, 
 
     processData: false, 
 
     contentType: false, 
 
     success: function (data, status) 
 
     { 
 
      console.log('Submission was successful.'); 
 
      console.log(data); 
 
     }, 
 
     error: function (xhr, desc, err) 
 
     { 
 
      console.log('An error occurred.'); 
 
      console.log(data); 
 
     } 
 
    });   
 
});
<form name="billing" id="billing" action="https://XX.XX.XX.XX/ghe/api2/call/jsonrpc2" method="POST"> 
 
    First Name: <input type="text" id="firstname" name="firstname"/> <br/> 
 
    Surname: <input type="text" id="surname" name="surname" /> 
 
<br/> 
 
    Email : <input type="text" id="email" name="email"/> 
 
<br/> 
 
    <input type="submit" name="submit" value="submit"> 
 
</form>
私はどこかで見た文字列化を使用して、試してみましたそれはまた、経由:

$("#submit").click(function() 
 
{ 
 
\t $("#billing").submit(function(e) 
 
\t { 
 
\t \t var postData = $(this).stringify(); 
 
\t \t var formURL = $(this).attr("action"); 
 
\t \t $.ajax(
 
\t \t { 
 
\t \t \t url: $form.attr('action'), 
 
\t \t \t type: "POST", 
 
\t \t \t data : postData, 
 
\t \t \t success:function(data, textStatus, jqXHR) 
 
\t \t \t { 
 
\t \t \t \t console.log("success"); 
 

 
\t \t \t }, 
 
\t \t \t error: function(jqXHR, textStatus, errorThrown) 
 
\t \t \t { 
 
\t \t \t \t console.log("Failed"); 
 
\t \t \t } 
 
\t \t }); 
 
\t }); 
 
\t \t 
 
\t $("#billing").submit(); //SUBMIT FORM 
 
});

しかし、私はまだその同じエラー解像度を取得しますポンセ。何が間違っているのですか?私の知るように、APIの使用については新しいので、今はちょっと散らかっています。 APIのURL最高の学習リソースを指摘できる場合..あなたは無効なJSON-RPC例外を引き起こしているかを確認するためにサーバーに送信されるペイロードをキャプチャする必要が

おかげ

答えて

0

をいただければ幸いです。

あなたの可能性はconsole.log(postData)です。 または、ブラウザのデバッガまたはfiddlerをお勧めします。

サーバーに送信されているjsonをキャプチャしたら、json linter jsonLint.comにドロップして問題の原因を確認できます。

関連する問題