无法在网页上查看JS API响应

时间:2019-10-03 15:06:08

标签: javascript ajax api

首先,我对使用API​​和JS非常陌生。

我已经使用PostMan创建了以下Get Request,它在JSON响应中完美地返回了预期的结果。

<script>
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "http://www.reed.co.uk/api/1.0/search?keywords=construction&location=sheffield",
  "method": "GET",
  "headers": {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Basic NWFmZTBmOTAtMzQ4MC00ZDQ3LTgyMDYtMzUyOTgxNWE2MTBhOg==",
    "User-Agent": "PostmanRuntime/7.17.1",
    "Accept": "*/*",
    "Cache-Control": "no-cache",
    "Postman-Token": "f69f3ecb-2e0c-4fcc-9cfa-796115805319,6cd343e2-d8d8-412e-b505-34218c69adca",
    "Accept-Encoding": "gzip, deflate",
    "Cookie": "__cfduid=d569febd387dab8f972be1c6b2e2bd4341570112246; jsSplitTestGroup=8; .ASPXANONYMOUS=DF9G8b4OJy1PLMCJfQ-MY2TYySziRwo3Bm2dh7UcE9XCMvpkGsIREQYCT0qhS28zfqtWcBrGFmyOWNvp7xrMpdntsx8vldDCHlF15cGeN8eqL4-iyRTCsBFEWaLYnFGpHT7Biw2",
    "Referer": "http://www.reed.co.uk/api/1.0/search?keywords=construction&location=sheffield",
    "Connection": "keep-alive",
    "cache-control": "no-cache"
  }
}

$.ajax(settings).done(function (response) {
  console.log();
});
</script>

现在,当我将其粘贴到.html页面中时,在控制台中未显示任何响应,也没有错误显示。

如何在网页上呈现JSON响应?

非常感谢

0 个答案:

没有答案