javascript - 无法在网页上查看 JS API 响应
问题描述
首先,我对使用 API 和 JS 非常陌生。
我使用 PostMan 创建了以下获取请求,它在 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 响应?
提前谢谢了
解决方案
推荐阅读
- r - 根据日期查找一个数据框中的所有行,查看 R 中其他数据框中的日期范围
- javascript - 无法读取未定义 C# JAVASCRIPT 的属性“长度”
- php - (初学者)如何在我的 index.php 文件中添加一个删除按钮,该按钮将从数据库中删除类别
- c++ - 找不到最新插入到 std::map 的密钥
- python - 使用复选框选项在 div 中显示多选引导下拉值
- ios - 如何在 UICollectionViewDelegateFlowLayout 中设置无间距?
- python - 计算算术表达式的程序
- css - 如何增加 scss 变量?
- tensorflow - Keras ImageDataGenerator 用于多个输入和基于图像的目标输出
- php - 如何使用 CloudConvert API