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 809095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:40:17+00:00 2026-05-15T00:40:17+00:00

I’m stuck in a rut. I hope some one can help. Basically, I am

  • 0

I’m stuck in a rut. I hope some one can help.

Basically, I am building an AJAX mobile web app with jQuery. I am able to parse a specific XML file just fine, but I want the option to parse other XML files based on the link they were clicked on and load them on the fly into the same DIV or UL.

So:

click on Link1, loads XML1
click on Link2, loads XML2

I would like to be able to do this all client side, so no PHP (or is that a bad idea?). This the jquery code I’ve been using:

$(document).ready(function() {          

        $("a.load_ajax").click(loadAjax());

        function loadAjax() {
            var fileID = get('?lineID=');

            var dataID = "xml/" + fileID + ".xml"

            $.ajax({
                type: "GET",
                url: dataID,
                dataType: "xml",
                success: parseXml
            });

            function parseXml(xml) {
                $(xml).find("train").each(function() {
                    $("ul#ajax-output").append('<li>' + $(this).find("time").text() + '</li>');
                });
            }
        }           

});

Its just not working at all. I have been passing the variable using GET in the url. So the link in the HTML goes to /?lineID=SBD_to_Union and it should load the XML file called SBD_to_Union.xml

Making sense to anyone? I’d appreciate some help.

  • 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-15T00:40:18+00:00Added an answer on May 15, 2026 at 12:40 am

    What you seem to be struggling with is obtaining the line from the url in the anchor. Use $(this) to get the href attribute of the clicked link. You could then use a regex, if the url is as described, to remove all but the line id to use in constructing the link for the XML. I presume that the XML is server side and relative to the current url. If not, then you’ll need to adjust the path. I’ve taken the liberty to compress things a bit by putting the functions inline. Edit: and the click handler should return false to prevent the link from actually performing its default action.

    $(function() {          
    
        $("a.load_ajax").click( function() {
            var fileID = $(this).attr('href').replace(/.*?lineID=/,'');
    
            var dataID = "xml/" + fileID + ".xml"
    
            $.ajax({
                type: "GET",
                url: dataID,
                dataType: "xml",
                success:  function(xml) {
                    $(xml).find("train").each(function() {
                        $("ul#ajax-output").append('<li>' + $(this).find("time").text() + '</li>');
                    });
                }
            });
            return false;
        });          
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.