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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:28:32+00:00 2026-06-17T22:28:32+00:00

I have an html site that doesn’t have page changes. It just loads different

  • 0

I have an html site that doesn’t have page changes. It just loads different elements into each position on the page using ajax calls. I need my login function to run after the page is loaded the first time (because it requires elements on index to exist), but when I use $(document).ready(login), it fires every time an element is loaded (since it loads elements onto the page, it gets stuck in an infinite loop). Other than placing it at the bottom of my index page (which seems pretty fragile) is there a way to make it load after the index page is finished loading, but not have it run everytime an ajax request adds something to the page?

My login function looks like this:

function login ()
{
    if($.cookie('employee'))
        employee = $.cookie('employee');

    if(employee && !employee.login)
        $("div.middle").load('login.html');
    else
            $("div.middle").load('main.html');

}

function logout ()
{
    //FIXME send a logout request to server to end session also
    employee = null;
    $.cookie('employee', null);
    $("div.middle").load('login.html'); 
}

and my initial ready function looks like:
//Global variables
var employee = new Object;

$(document).ready(function(){
        $("div.leftColumn").html(buildLeftNav());
        //set height of middle if height of leftColumn is less than height of middle
        if($("div.leftColumn").css('height') < $("div.middle").css('height'))
            $("div.center").css('height' , $('div.middle').css('height'));




        //handle login and logout
        $.cookie.json = true;
        login();


    });

I have set up a fiddle to illustrate: http://jsfiddle.net/uZVP4/

  • 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-17T22:28:34+00:00Added an answer on June 17, 2026 at 10:28 pm

    Your problem likely lies not in document.ready but that you are likely loading the same script over and over in the AJAX calls. Since script automatically loads new content, it is creating an infinite loop of load new content which causes new content to load again..over and over.

    If you must keep the scripts in remote pages you could use $.get which will not execute scripts within ajax content

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

Sidebar

Related Questions

I have a very complicated site built on CSS3 that has html elements 3d-transformed,
I have a live site that includes different php files depending on what page
I have a web site that contains an HTML form, in this form I
I have a Rails 2.1.2 site that only has html templates e.g. jobs.html.erb, so
I have a site that I'm creating, part in static HTML, the other part
I have this asp.NET web site that for some odd reason doesn't want to
Here's the site: http://joshnh.com/ Basically, I have a few elements that are super wide
I would like to crawl a popular site (say Quora) that doesn't have an
I have a site with many jQuery event handlers on each page, all in
I have a little site that's available in different languages which are selected based

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.