使用jQuery.ajax操作Web API响应

时间:2016-02-23 16:12:51

标签: jquery import.io

请帮助,我正在尝试返回键的值" Book"。



var lode = $("#result").load("https://api.import.io/store/connector/3bcafba9-b5f3-4feb-a248-6265c0119606/_query?input=webpage/url:https%3A%2F%2Fwww.packtpub.com%2Fpackt%2Foffers%2Ffree-learning&&_apikey=81c93652057b496d886a97b5465b35816a2e3c29f89aeb50093e05ceef67b1fb244271b5156fdafb31f67b08e9eb8a3b99f12fc06f2d6eb1f86d081e206b852b63487fc7f22be6301831da2dda4142fe").hide;

   // $.parseJSON("lode");
   // $('lode').(payload.results[0].book);

<body>
  <div id="result"></div>
  <script src="https://code.jquery.com/jquery.min.js"></script>
</body>
&#13;
&#13;
&#13;

我能够在JSON响应被硬编码时提取值,但以编程方式返回值的必需jQuery仍然无法实现。 非常感谢 http://jsbin.com/josuza/edit?html,js,output

1 个答案:

答案 0 :(得分:0)

var url = "https://api.import.io/store/connector/3bcafba9-b5f3-4feb-a248-6265c0119606/_query?input=webpage/url:https%3A%2F%2Fwww.packtpub.com%2Fpackt%2Foffers%2Ffree-learning&&_apikey=81c93652057b496d886a97b5465b35816a2e3c29f89aeb50093e05ceef67b1fb244271b5156fdafb31f67b08e9eb8a3b99f12fc06f2d6eb1f86d081e206b852b63487fc7f22be6301831da2dda4142fe";

$('#result').load(url,function(response,status,xhr) {
  $('#result').html($.parseJSON(response).results[0].book);
});

您可以使用此代码获取图书价值