I am trying to pull data from my XML sheet, this is the first time i have done this fyi.
Here is my jQuery.
$(document).ready(function(){
$.ajax({
type: "GET",
url: "desk.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('desk').each(function(){
var id = $(this).attr('id');
var desknum = $(this).find('desk#').text();
var phonenum = $(this).find('phone#').text();
var emailinfo = $(this).find('email').text();
$('<div class="desks" id="desk_'+id+'"></div>').html().appendTo('#page-wrap');
$('<div class="desknum"></div>').html(desknum).appendTo('#desk_'+id);
$('<div class="phonenum"></div>').html(phonenum).appendTo('#desk_'+id);
$('<div class="emailinfo"></div>').html(emailinfo).appendTo('#desk_'+id);
});
}
});
});
Here is my XML
<?xml version="1.0" encoding="iso-8859-1"?>
<location>
<desk id="1">
<desk#>Camaron</desk#>
<computer#>COR9838L</computer#>
<phone#>111.111.1111</phone#>
<email#>camaron@yahoo.com</email#>
<picture></picture>
</desk>
<desk id="2">
<desk#>Greg</desk#>
<computer#>COR9838L</computer#>
<phone#>111.111.1111</phone#>
<email>camaron@yahoo.com</email>
<picture></picture>
</desk>
<desk id="3">
<desk#>Cesar</desk#>
<computer#>COR9838L</computer#>
<phone#>111.111.1111</phone#>
<email#>camaron@yahoo.com</email#>
<picture></picture>
</desk>
<desk id="4">
<desk#>Tracy</desk#>
<computer#>COR9838L</computer#>
<phone#>111.111.1111</phone#>
<email#>camaron@yahoo.com</email#>
<picture></picture>
</desk>
</location>
I also setup a jsfiddle here http://jsfiddle.net/cornelas/Re6Nv/
Not sure why its not working.
Also I want to instead of creating a div id, i want my xml data to load to a correct div id. Just to give you an idea of what my plan is, i am building a location based format each desk will have an id on a map, the xml should point to the location on the map and place the data correctly. This is a big project so any help you can offer is greatly appreciated.
Your desk.xml returns a 500 Internal Server Error, also I suggest you use this code once your XML file is accessible.
http://jsfiddle.net/Re6Nv/6/