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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:33:16+00:00 2026-06-15T17:33:16+00:00

I am relatively new to jQuery and pardon if this question is too simple,

  • 0

I am relatively new to jQuery and pardon if this question is too simple, but I’ve searched numerous threads for hours and cannot find a definite solution.

I have the following folder structure:

/index.html

/html/pages/page1.html
/html/pages/images/
/html/pages/css/
/html/pages/js/
/html/pages/includes/

I am trying to load page1.html into a DIV in index.html in the following basic way:

$('#content').load('html/pages/page1.html', function () {
   console.log('loaded');
});

page1.html loads fine, however, it consists of multiple includes and all the content in it (images, CSS, JS, etc.) is relative to the pages folder (for example: ../images/header.jpg), so it does not show when loaded into index.html since now everything becomes relative to / or index.html.

I read somewhere that making all paths absolute or root relative in page1.html will work, also adding sort of a global path variable, however, the PROBLEM is that there is too much legacy content and changing all of it is not an option.

Is there a way to do load page1.html as described above without modifying any of the paths, despite that they’re relative? Or can someone recommend an efficient way (other plugins, techniques) of loading external content this way?

Thank you!

  • 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-06-15T17:33:17+00:00Added an answer on June 15, 2026 at 5:33 pm

    If everything is relative to the pages folder, then you can use some simple searching and replacing. This isn’t the best programming practice, as it is not as flexible (going from relative to absolute in this type of context is relying on a number of factors working properly) as it should be, but it will work.

    $.get('html/pages/page1.html', {}, function(data, status, xhr) {
        var updatedData = data.replace(/\.\.\/(images|css|js)+/g, "http://www.mywebsite.com/html/$1");
    
        $('#content').html(updatedData);
    });
    

    Edit:

    You could also use a proxy script and rewrite/route all requests to this folder to the proxy script. I don’t know what server-side technology you are using, but you could do this:

    Using .htaccess (or the like), redirect all requests directed to this folder to another script in your codebase. In the script, look for the path that is incoming to the script, load the original output contents, perform a search/replace and output the contents to the buffer. In addition, you can set up caching on the server so that the client would cache the requests lowering the processing overhead that you might experience (though, I would anticipate that to be fairly minimal).

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

Sidebar

Related Questions

I am relatively new to jQuery so this may be a beginners mistake, but
I am relatively new to JQuery, so please excuse this question if it seems
Im relatively new to the Android world but I have a quick question. I
I am relatively new to jQuery but the below code seems logical but is
I am relatively new to this, but I'm working through things. I want to
This may be a simple question but I can't seem to get my head
Hi I am relatively new to jQuery and JavaScript and have a question regarding
I am relatively new to jQuery, and I seem to be stuck with this
I am relatively new to jQuery, I am trying to work around this code
I'm relatively new to Jquery so please feel free to slap me if this

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.