json到ul的链接和文本

links and text from json to ul

本文关键字:文本 链接 ul json      更新时间:2023-09-26

你能帮我为什么不起作用吗?

$.ajax({
  url: 'https://api.import.io/store/connector/b5caf0ef-1e6b-4fba-9fa4-21e475196673/_query?input=webpage/url:http%3A%2F%2Fnuzzel.com%2FWAStatzz%3Fsort%3Dfriends%26when%3D2&&_apikey=e4fb993c758a43dda0ca9135d3b3264deebed4b302b0d342e2b3fabb2b49afc9c14493d0d53d65d0ea2a0fd19b45f6d10cda5252f76410921188d38cb4e6db8fc28527d64207329b2c86bdc5119bac97'
}).done(function(data) {
  console.log(data);
  var html = "";
  $.each(data.results, function(index, item) {
    html += "<ul>";
    html += "<li>" <a href="['headline']"> + item['headline/_text'] + "</a>""</li>";
    html += "<li>" + item.description + "</li>";
    html += "</ul>";
  });
  setTimeout(function() {
    $(".container").append(html);
  }, 1500);
})

https://jsfiddle.net/byxmao00/

您的报价在这两行有一些问题

html += "<li>" <a href="['headline']"> + item['headline/_text'] + "</a>""</li>";
html += "<li>" + item.description + "</li>";

它应该像这个

html += "<li><a href='" + item['headline'] + "'>" + item['headline/_text'] + "</a></li>";
html += "<li>" + item.description + "</li>";

更新的小提琴:https://jsfiddle.net/byxmao00/2/

编辑:只有第一行,对不起。