Click here to Skip to main content
15,891,762 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a newbie, can someone tell me what I am doing wrong in the following jquery? I am trying to parse a xml file. I am getting no errors...or output

XML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function()
     {
       $.ajax({
         type: "GET",
         url: "C:\Users\Owner\Documents\Development\javascripts\Mission.xml",
         dataType: "xml",
         success: parseXml
       });
     });
     //print the date followed by the title of each Mission
     function parseXml(xml)
     {
         $(xml).find("Mission").each(function()
         {
           $("#output").append($(this).attr("ID")");
           $("#output").append("," + $(this).attr("OrgID")");
           $("#output").append("," + $(this).attr("Name")");
           $("#output").append("," + $(this).attr("Date")");
           $("#output").append("," + $(this).attr("nTouched")");
           $("#output").append("," + $(this).attr("HowTouched")");
         });
     }
 </script>

here is sample input data:
Posted

1 solution

hello,

I suspect it has something to do with the URL. Try deploy it to local IIS or web hosting to test it. If you need further example, you can look at JQuery slide-show with XML. I would recommend test it by using absolute path first the relative path.

http://blog.ysatech.com/post/2009/10/08/JQuery-slideshow-with-XML.aspx[^]


Thanks,
Bryian Tan
 
Share this answer
 
Comments
bobby2009 25-Jul-11 23:37pm    
ok, I corrected the url and added some alert statements and retested in firefox to make sure I was going through the code. I am not getting any output... any ideas?
//print the date followed by the title of each Mission
function parseXml(xml)
{
$(xml).find("Mission").each(function()
{
$("#output").append($(this).find("ID").text());
$("#output").append("," + $(this).find("OrgID").text());
$("#output").append("," + $(this).find("Name").text());
$("#output").append("," + $(this).find("Date").text());
$("#output").append("," + $(this).find("nTouched").text());
$("#output").append("," + $(this).find("HowTouched").text() + "<br />");
});
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900