Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7527137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:02:21+00:00 2026-05-30T04:02:21+00:00

I have some jQuery with an Ajax call that looks like this: $.ajax({ type:

  • 0

I have some jQuery with an Ajax call that looks like this:

$.ajax({
    type: "GET",
    url: "xml/photobank.xml",
    dataType: "xml",
    success: function(xml){
        xmlParser(xml, "Charlie");
    }
});

function xmlParser(xml, landOwner) {

    //Initial photos do not load if following line is used.
    //xml = $.parseXML(xml);

    $('#photo_container').empty();
    console.log('1');
    $(xml).find('Landowner').each(function(){
        console.log('2');
        var landownerName = $(this).attr('Name');
        if (landownerName === landOwner) {
            $(this).find('Photo').each(function(){
                $("#photo_container").append('<div class="photo ' + $(this).find("Category").text().toLowerCase() + '"><p>' + $(this).find("Animal").text() + '</p>'+ '<img class="photobank" src="images/' + $(this).find("Image").text() + '" />' + '</div>');
            })
        }
    });
}

You can see the XML file here: http://lamanai.org/catmap/xml/photobank.xml

However, the Ajax does not display the parsed XML, and throws this error in Chrome’s console: Uncaught Error: Invalid XML: [object Document]. Am I calling the Ajax at the wrong time? Right now it is on document ready, since I need the initial “Charlie” category parsed on the initial page load.

If I remove the xml = $.parseXML(xml); line, the initial parsed XML does load, but then I get Uncaught ReferenceError: xml is not defined errors when trying to use the xmlParser function afterwards.

Any hints? This is my first encounter with Ajax.

HTML: http://lamanai.org/catmap/

JS: http://lamanai.org/catmap/js/cameramap.js

XML: http://lamanai.org/catmap/xml/photobank.xml

—

Update: The xml = $.parseXML(xml); line was removed, but now I’m having trouble re-using the function. The following code results in xml is not defined errors.

$('#btn_arnoldo').click(function(){
    xmlParser(xml, "Arnoldo");
});

I can use the following Ajax call instead, and have it work, but is it really necessary to do the Ajax each time I want to switch what part of the XML I want to use? I thought the initial Ajax gives me an object that I can parse from?

$('#btn_arnoldo').click(function(){
    $.ajax({
        type: "GET",
        url: "xml/photobank.xml",
        dataType: "xml",
        success: function(xml){
            xmlParser(xml, "Arnoldo");
        }
    });
}); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:02:23+00:00Added an answer on May 30, 2026 at 4:02 am

    It looks like it is already parsed. Your xml object seems to contain an xml document already, while parseXML is supposed to be used to convert an XML string to an XML document. If you want to access all the Image tags, you should be able to use jQuery to iterate all of them using each.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
I have a jQuery AJAX call that creates and displays a form like this
In my application I have some table data that looks like this: <table> <tr>
Hei guys i have this JQuery Ajax call from my view and it looks
I have some jquery code that is doing an ajax lookup and returning comma
I have some content that I am loading using jquery ajax. The content has
I have some jQuery code like this : $(function($) { $('input.autonumeric').autoNumeric({aSep: ',', aDec: '.',vMax:'1000000000000'});
I have a jquery ajax call that goes to the create action, and I
I have an AJAX call that I want to run against a WCF GET
I have a form that looks something like this: <form id=uploadForm name=uploadForm method=post enctype=multipart/form-data>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.