2017-08-19 3 views
0

shapeshift.ioからデータを取得するためのjqueryコードがあります 私がPostmanを使用してテストすると、データは正常です。 しかし、jQueryからのデータは未定義です。shapeshiftのJsonオブジェクトは返されません

jQuery("#btnSubmit").click(function(){ 
    var param = {"withdrawal": "0x242AcBe58c4f3b514E72297EA0Ed0d847F1123BE" , "pair": "btc_eth"}; 

    jQuery.ajax({ 
     dataType : 'json', 
     type  : 'POST', 
     contentType : 'application/json;charset=UTF-8', 
     url   : 'https://shapeshift.io/shift', 
     data  : JSON.stringify({data : param}), 

     success: function(data,status) { 
      alert("Data: " + data.deposit + "\nStatus: " + status); 
     }, 
     error: function(){ 
      alert("error"); 
     } 


    }); 
}); 

答えて

0

これは出力ですか? JSON.Stringify()は1つのオブジェクトを取り、それを文字列化します。
は以下のスニペットを確認してください。

jQuery("#btnSubmit").click(function(){ 
 
     var param = {"withdrawal": "0x242AcBe58c4f3b514E72297EA0Ed0d847F1123BE" , "pair": "btc_eth"}; 
 

 
     jQuery.ajax({ 
 
      dataType : 'json', 
 
      type  : 'POST', 
 
      contentType : 'application/json;charset=UTF-8', 
 
      url   : 'https://shapeshift.io/shift', 
 
      data  : JSON.stringify(param), 
 

 
      success: function(data,status) { 
 
       alert("Data: " + data.deposit + "\nStatus: " + status); 
 
      }, 
 
      error: function(){ 
 
       alert("error"); 
 
      } 
 

 

 
     }); 
 
    });
<a href="#" id="btnSubmit">click</a> 
 
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

+0

をはい、それはそれです。どうもありがとうございました。 –

関連する問題