【发布时间】:2021-08-07 05:08:57
【问题描述】:
我只是在尝试一些新的东西来获得最新的技能,并且对这个 jQuery API 响应有点难过。我的所有结果都可以正常显示,我让它们显示在一个 html 文件上,但它们都作为一个整体。我想在每个单词之间打断(它是 [Words API][1],我被卡住了。我通常使用 PHP,但是,这对于我的计划来说并不实用。这是代码,我我会在结果中显示出最好的结果。谢谢!
<div id="div1">
// This is where it shows up as "unmitigated,butcherly,crimson,gory,homicidal,internecine"
</div>
<script>
const settings = {
"async": true,
"crossDomain": true,
"url": "https://wordsapiv1.p.rapidapi.com/words/bloody/similarTo",
"method": "GET",
"headers": {
"x-rapidapi-key": "<my key>",
"x-rapidapi-host": "<host>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
$("#div1").html(response.similarTo + " "); // This puts a comma between each word, but no spacing, when I want a line break. I need to be able to customize results, make them links, add styles, etc.
});
非常感谢!只有 3 周严格的“待在家里”Covid19 命令。我学到了很多东西!
【问题讨论】:
-
嗨,你能显示
response的输出吗?