I have written a C code for getting the list of youtube videos for the url
"*http://gdata.youtube.com/feeds/api/standardfeeds/top_rated*" using the libsoup library.
I can parse the returned xml data using libxml2 and extract the desired fields from it.
I want to know how can i do the same using javascript and display the list on a browser. I have very basic knowledge on javascript but i am willing to put in the needed effort if you guys point me in the right direction.
I understand the following from the google help documentation for youtube APIs.
- Send a GET request in desired format to the url mention.
- Response will be xml or json-c format and this has to be parsed
How do i achieve both of these using javascript and display using html/javascript? Sample code or any links will be of great help.
Edit : Adding php tag for better visibility of the question and i think php may be able to provide hints for the question.
TIA,
Praveen S
EDIT after trying the suggestions given below:
How do i debug this?
It doesnt seem to display the title of the videos which i intend to enlist.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("body").append("<div id = 'data'><ul>jffnfjnkj</ul></div>");
$.getJSON("http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?callback=function&alt=jsonc&v=2", function(data) {
var dataContainer = $("#data ul");
$.each(data.data.items, function(i, val) {
$("body").append("<div id = 'data'><ul>jffnfjnkj</ul></div>");
if (typeof(val.player) !== 'undefined' && typeof(val.title) !== 'undefined') {
dataContainer.append("<li><a href = "+val.player.default+" target = '_blank'>"+val.title+"</a></li>");
}
});
});
});
});
</script>
</head>
<body>
<h2>Header</h2>
<p>Paragrapgh</p>
<p>Paragraph.</p>
<button>Click me</button>
</body>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…