简体   繁体   中英

links and text from json to ul

can you help me why is this not working?

 $.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/

You have some issues on these 2 lines with your quotes

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

it should be like this

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

Updated fiddle: https://jsfiddle.net/byxmao00/2/

Edit: Only the first line, sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM