SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Location
    North Wales
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery AJAX Problem

    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.

    Code:
     <row field1="value1" field2="value2" field3="value3" >


    I use jQuery to load and display as a table

    Code:
    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
    Matthew Higgins
    My Blog

  2. #2
    SitePoint Enthusiast TriLLi's Avatar
    Join Date
    Feb 2010
    Location
    BiH, Bugojno
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post xml from response?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •