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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:18:29+00:00 2026-05-17T02:18:29+00:00

I’m using Ajax to dynamically populate a DIV. I have each page content stored

  • 0

I’m using Ajax to dynamically populate a DIV. I have each page content stored in XML files as CDATA. When a user clicks on a link from the navigation bar, the Ajax loads the XML for that particular page, parses it, and populates the DIV with it’s content.

Everything is working GREAT, except for one thing. I have a jQuery modal popup whose markup is loaded from that page’s XML file. The .js and .css files from the jQuery plugin are all loaded, and when this is HARD CODED (i.e., not loaded from XML), it works fine. But when it’s loaded from the XML, the modal doesn’t work.

When the page is loaded from the XML file- What the page is supposed to do is load the HTML from the XML file, which it does, and there’s a hyperlink that when clicked, it’s supposed to create the modal popup window. Instead, clicking on the link does NOT fire up the modal popup window.

When the page is hard coded- it does everything it’s supposed to do.

A live example is at:

http://mikemarks.net/clientSites/tabras/

Click on “The Band”, and at the bottom you’ll see the hyperlink called “Demo”. Clicking on that should bring up a modal popup window, but instead as you can see it just takes you to the top of the page.

Below is my markup (notice the div id=”copy”, which is the placeholder for my HTML content that’s loaded from the XML file), my Ajax JavaScript code, and my XML file (which is shown as the markup that’s loaded into the div id=”copy”).

<div id="leftTwoThirdsColumn">
            <div id="menu">
                <ul class="menu">
                    <li style="width:65px;"><a id="default" href="#" onclick="makeRequest('xml/default.xml');"><span>Home</span></a></li>
                    <li style="width:65px;"><a id="lyrics" href="#" onclick="makeRequest('xml/lyrics.xml');"><span>Lyrics</span></a></li>
                    <li style="width:110px;"><a id="merch" href="#" onclick="makeRequest('xml/merch.xml');"><span>Merchandise</span></a></li>
                    <li style="width:93px;"><a id="bio" href="#" onclick="makeRequest('xml/bio.xml');"><span>The Band</span></a></li>
                    <li style="width:80px;"><a id="contact" href="#" onclick="makeRequest('xml/contact.xml');"><span>Contact</span></a></li>
                    <li style="width:150px;" class="last"><a id="friends" href="#" onclick="makeRequest('xml/friends.xml');"><span>Friends of Tabr&auml;s</span></a></li>
                </ul>
            </div>
            <br /><br />

            <div id="copy">

            </div>
        </div>

function makeRequest(url) 
{
    if(window.XMLHttpRequest)
    {
        request = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        request = new ActiveXObject("MSXML2.XMLHTTP");
    }

sendRequest(url);

}

function sendRequest(url)
{
request.onreadystatechange = onResponse;
request.open("GET", url, true);
request.send(null);
}

function checkReadyState(obj)
{
if(obj.readyState == 0) { document.getElementById('copy').innerHTML = "Sending Request..."; }
if(obj.readyState == 1) { document.getElementById('copy').innerHTML = "Loading Response..."; }
if(obj.readyState == 2) { document.getElementById('copy').innerHTML = "Response Loaded..."; }
if(obj.readyState == 3) { document.getElementById('copy').innerHTML = "Response Ready..."; }
if(obj.readyState == 4)
{
if(obj.status == 200)
{
return true;
}
else if(obj.status == 404)
{
// Add a custom message or redirect the user to another page
document.getElementById('copy').innerHTML = "File not found";
}
else
{
document.getElementById('copy').innerHTML = "There was a problem retrieving the XML.";
}
}
}

function onResponse()
{
if(checkReadyState(request)) {
var response = request.responseXML.documentElement;
var root = new Array();
root = response.getElementsByTagName('');
//alert("Total Number of HTML Elements Found: " + response.getElementsByTagName("
").length);
var html = '';
for (var i = 0; i < root.length; i++) {
var tagName = response.getElementsByTagName("").item(i).nodeName;
var tagObj = response.getElementsByTagName("
").item(i);
html += tagObj.firstChild.nodeValue;
}
document.getElementById('copy').innerHTML = html;
}
}

<div style="padding-top:5px; margin-left:auto; margin-right:auto; text-align:center;"> <img src="images/ShawnBioActive.png" /> <img src="images/JasonBioActive.png" /> <img src="images/WillBioActive.png" /> <img src="images/RasoulBioActive.png" /> <img src="images/bioStrip.png" /> <div id='basic-modal'><h3>Basic Modal Dialog</h3><p>A basic modal dialog with minimal styling and no additional options. There are a few CSS attributes set internally by SimpleModal, however, SimpleModal relies mostly on style options and/or external CSS for the look and feel.</p><input type='button' name='basic' value='Demo' class='basic'/> or <a href='#' class='basic'>Demo</a></div><script type="text/javascript" src="../js/modal/jquery.simplemodal.js"></script><script type="text/javascript" src="../js/modal/basic.js"></script><link type="text/css" href="../css/modal/demo.css" rel="stylesheet" media="screen" /><link type="text/css" href="../css/modal/basic.css" rel="stylesheet" media="screen" /><script type='text/javascript'>jQuery().ready(function () {$('#basic-modal-content').modal();});</script> <div id="basic-modal-content"><h3>Basic Modal Dialog</h3></div><div style='display:none'><img src='images/modal/basic/x.png' alt='' /></div></test2> </div>

  • 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-17T02:18:29+00:00Added an answer on May 17, 2026 at 2:18 am

    It seems that your webpage lacks of jquery.simplemodal.js and basic.js and the css associated ( for example, for the display:none; on your basic-modal-content )

    That’s why you don’t have any modal on load.

    Plus, your link or button doesn’t have any event handler (for example, $(‘.basic’).click(…);)

    That’s why you don’t have any other action than the anchor.

    To remove the anchor action, I recommand to use event.preventDefault

    • 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.