I have a large xml file which contains news, articles, reviews, etc. I wanna use AJAX and get only news displayed in a
<div>
I have a large xml file which contains news, articles, reviews, etc. I wanna use AJAX and get only news displayed in a
<div>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
xmlFile = "data.xml"; /* URL of XML File. Must be on the same domain */
$(function() {
$.ajax({
type: "GET",
url: xmlFile,
dataType: "xml",
success: function(xml) {
$('.load').hide('fast');
$(xml).find('div').each(function(){
$('<li></li>')
.html($(this).html());
.appendTo('#news');
});
}
});
});
</script>
</head>
<body>
<ul id="news">
<li class="load">Please Wait. Loading...</li>
</ul>
</body>
-- jQuery to do that...
Change the url in the script (the ajax url), and it should work.
The code was adopted from http://www.xml.com/pub/a/2007/10/10/jquery-and-xml.html
Good Luck!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.