What I'm trying to find a way to do is load some data from xml, and load it on a page dynamically with a click on a link. Is this possible? Is there anyway someone can point me in the 开发者_运维知识库right direction? Is it possible to make a link call a javascript function?
To do this easily, you could use jQuery. It will auto-detect XML, but you can also force it:
$('#link').click(function(){
$.ajax({
url: 'yourXMLfile.xml',
dataType: 'xml',
success: function(data) {
$(data).find('xmltag').each(function(i,el){
alert( $(this).text() );
});
}
});
return false;
});
The code above will alert all text of all <xmltag>
tags
精彩评论