Reputation: 16117
I am loading an XML file then I will display the contents of it depending on their tag, but it seems my Code is not working. Here is my XML
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<word>
<threeletter>RIP</threeletter>
<fourletter>PIER</fourletter>
<fiveletter>SPIRE</fiveletter>
<sixletter>SPIDER</sixletter>
</word>
</xml>
Here is my Ajax code
$(document).ready(function() {
$.ajax({
url: "dictionary.xml",
success: function( xml ) {
$(xml).find("sixletter").each(function(){
$("ul").append(
"<li>" + $(this).text() + "</li>");
});
}
});
})
Both of them are in the same folder.
Upvotes: 0
Views: 288
Reputation: 1205
Your code works for me, using jQuery 1.7.1
Perhaps you don't have universal read access on the xml file? Navigate your browser to your xml file, if it doesn't load, there's your problem.
Upvotes: 1
Reputation: 100175
Try adding dataType:
$(document).ready(function() {
$.ajax({
url: "dictionary.xml",
dataType: "xml",
success: function( xml ) {
$(xml).find("sixletter").each(function(){
$("ul").append(
"<li>" + $(this).text() + "</li>");
});
}
});
})
Hope it helps
Upvotes: 0