Jump to content

Loading files from other locations


ohad

Recommended Posts

Hi All

I have a site which is built from 3 folders:

folder1

frolder2

frolder3

folder1 is the "master" folder. Means, In it I have the login page, connecxtion to DB elements, and header, footer and bootstrap treeview sidebar which I want to use in all the pages of the site.

folders 2 and 3 each store all pages concern a specific vertical. 

The sidebar, which is located at folde1 retrive the content from database using AJAX, and Ive overloaded some of the original css by using custom css.

here is psrt of the sidebar code:

<link href="custom.css" type="text/css" rel="stylesheet" madia="all"/>  
<script type="text/javascript">
               $(document).ready(function()
            {
                var treeData;
                $.ajax
                ({
                    type: "GET",  
                    url: "fill_sidebar.php",
                    dataType: "json",   

 

When I load this sidebar to pages inside folder1 all works great

The loading is done by this code:

<script>
	$(document).ready(function ()
    {
    	$('#sidebar').load('sidebar.php');
    });
</script>

The loading for folder 2 is done by this code:

<script>
	$(document).ready(function ()
    {
    	$('#sidebar').load('../folder2/sidebar.php');
    });
</script>>

 

When I try to load it to pages from other folder2 or 3 I get erroe message (in developer tools):

folder2/custom.css net::ERR_ABORTED 404 (Not Found)

jquery-3.5.1.js:10099 GET http://localhost/xxx/folder2/fill_sidebar.php 404 (Not Found) 

Of course, I i copy these files to folder2 all works fine, but I dont want to do that. I want to maintain only one file.

My question is how to make these loads relative to the page I load?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.