AJAX: Bringing in new content to display beneath the triggering page

Here is the code for my main page:

<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

    <style type="text/css">
        div
        {
            width:100%;
            height:100px;
            background-color:rgba(189,123,124,1.00);
            position:absolute;
            bottom:0;

            /* ensure this div remains on top */
            z-index:9000;
        }
        .container
        {
            /* make sure the loaded page appears below the div */
            z-index:200;
        }
    </style>
    </head>
    <body>

        <div>
            <div class="container">
            </div>
        </div>

        <script type="text/javascript">
            $(document).ready(function()
            {
                $(window).on("click", function()
                {
                    $("div.container").load("Page1.html");
                });
            });
        </script>

    </body>

As shown above, I have attempted to keep the red div bar at the bottom always visible even when Page1.html is loaded upon clicking the browser window.

Now, let's take a look at the code for Page1.html:

<head>
<style type="text/css">
    body, html
    {
        height:100%;
    }
    div
    {
        width:100%;
        height:100%;
        background-color:rgba(171,147,136,1.00);
    }
</style>
</head>

<body>
    <div>Page One</div>
</body>

However, upon loading Page1.html, it covers the red div bar completely and the bar disappears. It seems that the Z-Index property is not effective here. How can I resolve this issue?

You can view the actual page here:

Answer №1

Consider the following approach

index

 <head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

    <style type="text/css">

        .footer
        {
            /* ensure that the loaded page appears below this div */
            z-index:200;
            width:100%;
            height:100px;
            background-color:rgba(189,123,124,1.00);
            position:absolute;
            bottom:0;

            /* make this div the highest in z-index order */
            z-index:9000;
        }

        body, html
    {
        height:100%;
    }

    </style>
    </head>
    <body>


        <div class="holder"></div>

     <div class="footer">
            </div>

        <script type="text/javascript">
            $(document).ready(function()
            {
                $(window).on("click", function()
                {
                    $("div.holder").load("Page1.html");
                });
            });
        </script>

    </body>

Page1

<style type="text/css">
    .data
    {
        width:100%;
        height:100%;
        background-color:rgba(171,147,136,1.00);
    }
</style>


    <div class="data">Page One</div>

I made changes to remove head and body tags from Page1 for valid HTML structure. It's important to separate partial views/pages without header or layout when appending them to existing pages.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Highcharts: Border of stacking bar chart not visible on the right side

When creating a stacking bar chart, I noticed that the rightmost 'box' does not have a border drawn on the right side. Is there a setting or option in Highcharts that can be used to ensure the white border line is drawn around the 75% box in the ...

Implement a dispatcher in raw JavaScript using React combined with the Redux Toolkit package

In my React app, I have been using Redux and Redux Toolkit within React components by utilizing the useDispatch and useSelector hooks. However, I now need to update the Redux store from a pure JavaScript module that interacts with IndexedDB to save user da ...

What could be the reason for the absence of the CSS destination folder being generated by

My colleague has the exact same code and can run gulp without any issues, but I'm struggling to compile the css files using Gulp. Gulp isn't creating the css destination file or the css files themselves. However, it works perfectly fine for build ...

ajax ignores output from php

I've been working on passing PHP echo values through AJAX, but I've encountered a problem where the if and else conditions are being skipped in the success function of AJAX. Even when the if condition is met, the else statements are still being e ...

In the world of Node.js and Java, the concepts of "if"

Here is a code snippet that I am working with: var randFriend = friendList[Math.floor(Math.random() * friendList.length)]; if (randFriend == admin) { //Do something here } else if (randFriend != admin) { client.removeFriend(randFriend); } I am tr ...

Make sure to fully load the HTML page before running the PHP code

Here is the code snippet I am currently working on: <div class="text-center"> <img src="img/ford_lodding.gif" alt="Loading GIF" style="width: auto; height: 500px;"> </div> <?php require 'php/loading.php';?> The cont ...

Displaying Wordpress posts in various columns

Typically, I enjoy solving problems on my own, but I have hit a roadblock with this one and haven't been able to find a solution online. I am wondering if there is a way in WordPress to choose which column a post (with its thumbnail) appears in. For e ...

An issue occurred during the construction of an angular project: The Tuple type '[]' with a length of '0' does not contain any elements at index '0'

When I run the command ng build --prod, I encounter the following error: ERROR in src/app/inventory/inv-parts-main-table/dialog-component/dialog-component.component.html(5,16): Tuple type '[]' of length '0' has no element at index &apo ...

I am experiencing an issue with applying responsiveFontSize() to the new variants in Material UI Typography

I am looking to enhance the subtitles in MUI Typography by adding new variants using Typescript, as outlined in the documentation here. I have defined these new variants in a file named global.d.ts, alongside other customizations: // global.d.ts import * a ...

Problem with Cakephp 2.2: Using Jquery Ajax with Js->link to save multiple entry ids on a single page

Is it possible that this question has already been addressed elsewhere? Despite my efforts, I have not been able to locate the answer. Cakephp is usually a reliable platform for me, but currently, it's causing me a lot of frustration. I am attempting ...

Using ASP.NET MVC, pass a list of values separated by commas to an action method

Hey there, I'm facing an issue with an ajax call where I am trying to retrieve values from an html select multiple tag. The problem arises when I attempt to pass these values into my controller as I keep getting a null reference error in my controller ...

The AJAX navigation feature does not function properly on Windows or Safari browsers, whether on a Mac or PC

Currently, I am facing an issue with a menu that is loaded via jQuery but maintained in a separate html file. The purpose of keeping it separate is to update it in one place rather than having to make changes on every page. The menu was functioning properl ...

Maintain visibility of the vertical scroll bar while scrolling horizontally

Currently, I am in the process of setting up a table with fixed headers and columns that have a minimum width. To ensure this setup functions correctly, I require both vertical and horizontal scroll bars. The vertical scroll bar should only navigate throu ...

Custom Joi middleware in Express v4 is failing to pass the Request, Response, and Next objects

I am currently in the process of developing a unique middleware function to work with Joi that will be placed on my routes for validating a Joi schema. In the past, I have created middlewares for JWT validation without passing any parameters, and they wor ...

Ways to ensure that two divs have equal heights based on whichever one has the greater height using CSS

I need help with adjusting the heights of two divs inside a container div using CSS. Specifically, I want the height of the img_box div to match the height of the content_con div based on their actual content. For example, if the content_con div contains t ...

Creating a multi-dimensional array in order to store multiple sets of data

To generate a multidimensional array similar to the example below: var serviceCoors = [ [50, 40], [50, 50], [50, 60], ]; We have elements with latitude and longitude data: <div data-latitude="10" data-longitude="20" clas ...

Arrangement of 'const' variables within React Stateless Components

Consider a scenario where I have a straightforward React stateless component: const myComponent = () => { const doStuff = () => { let number = 4; return doubleNumber(number); }; const doubleNumber = number => { ...

Node.js routing issues leading to rendering failures

I have been working on a website that involves carpooling with drivers and passengers. When a driver submits their details, they are directed to a URL where they can select the passenger they want to ride with. Here is the code snippet I have written: ap ...

Shifting an identification to the following element with the help of jQuery

I need to transfer an ID from one element to the next select element on the page. I am facing this challenge because the software used to create the select boxes does not allow for classes or ids to be directly added to select elements. Additionally, I am ...

Dealing with the problem of delayed image loading in AngularJS due to a setTimeout conflict

The issue: Upon page load, some images are still processing and not displaying (even though the image URLs are known). The resolution: To address this problem, a customized directive was developed to showcase a loading spinner as a placeholder until the i ...