Here’s the scenario; I have a PHP script that creates an XML file, the file contains the database records, effectively search results, which I use jQuery to load and display as a table.
<row field1="value1" field2="value2" field3="value3" >
I use jQuery to load and display as a table
var data = "<table>";
$.get('myxml.php', function(theXML){
$('row',theXML).each(function(i){
var field1 = $(this).find("row").attr("field1");
var field2 = $(this).find("row").attr("field2");
var field3 = $(this).find("row").attr("field3");
data = data + '<tr><td>' + field1 + '</td><td>' + field2 + '</td><td>' + field3 + '</td></tr>';
});
data = data + "</table>";
$("#results").html(data);
The problem is that the first record always has all the values listed as ‘undefined’, and appears last.
Any ideas?
Thanks
Matthew