简体   繁体   中英

JQuery : How get Json Key And Value by and this append (insert into ) list (ul)?

Please take a look at this jsFiddle: http://jsfiddle.net/xY7tx/3108/

When I run getJSON in the above sample, why is the fail part always triggered?

I would really appreciate if one tell me how with jQuery (or even with pure Javascript) How could get the key and value of the JSON file.

My goal is after getting the key ( title ) and the value ( video_url ) then insert them all into a list ul which the items of the list are the keys and the href are their values. Thanks

Because it's not JSON data. You're getJSON ing an HTML page.

Try it with the following link:

$.getJSON("https://raw.githubusercontent.com/xldrx/kodi-persian-contents/master/movies/movies.json", function(d) {
        console.log(d);
    }).fail( function(d, textStatus, error) {
        alert("getJSON failed \n , status: " + textStatus + "\n "+ ", error: "+error + "\n")
    });

As for the list, not sure I fully understood your requirement, but is this what you're looking for: https://jsfiddle.net/p77ymjgx/ ?

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