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

  • Home
  • SEARCH
  • 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 751797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:42:28+00:00 2026-05-14T14:42:28+00:00

I have an AJAX call to load a function once the page is loaded,

  • 0

I have an AJAX call to load a function once the page is loaded, the function opens a lightbox a like frame with some data. The issue is that if I click on close (lightbox frame), the page loads again and again loading the frame so the use never reaches the page under the layer of frame since the frame load on infinite loop. The Ajax is repeating calling the function I guess but I would like to load the frame once and when the user clicks X (close) he may return to the original page.

$(document).ready(function(){
var city = $('#citycode').html();

$.ajax({
//when page is loaded, fire the following function
success: function(){
//the function to be fired located in the page in seperate file
openX(city + //some other parameters);
}});


});

Any tips?

  • 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-14T14:42:29+00:00Added an answer on May 14, 2026 at 2:42 pm

    You can set a global variable on top of the page and set it to true once the page was loaded then later in your code you check if the variable is false load the page not other wise. Here is the prototype:

    <script type="text/javascript">
    
    var loaded = false;
    
    $(document).ready(function(){
    var city = $('#citycode').html();
    
    $.ajax({
    //when page is loaded, fire the following function
    success: function(){
    if (loaded === false)
    {
      //the function to be fired located in the page in seperate file
      openX(city + //some other parameters);
      loaded = true;
    }
    }});
    
    
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this ajax call: $('.ajaxtrigger2').click(function(){ $('#target').load('xxx.html'); ... how to append a Loading msg
Im using jquery to call a page via ajax. I have some jquery functions
I have coded some JavaScript to perform an ajax call in an asp.net application.
I have $.ajax({ url: identity, success: function(data) { ProcessIdentityServer(data) } }); When 'data' is
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
I have this code that performs an ajax call and loads the results into
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
As the title mentions, I have a timeout callback handler on an ajax call,
I have some AJAX work that brings across an additional form element that I
I'm having some issues with a jQuery AJAX call. My code works fine when

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.