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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:20:01+00:00 2026-05-23T23:20:01+00:00

i have a question regarding partial page loading with AJAX. Suppose that an user

  • 0

i have a question regarding partial page loading with AJAX.

Suppose that an user clicks on a button that makes an AJAX call to load part of a page (it can possibly include dynamically loaded JS and/or CSS), and the html content is dropped on some div. Then, before the first load is complete he clicks on another button that makes another AJAX call that drops other content on the same div. How should i prevent this behaviour to create any conflicts? Some possible conflicts might be something like, for example, the first load executes some JS on content that is not found because the second load already changed that div.

Thanks in advance.

Edit:
I would appreciate answers based on asynchronous methods. Thanks.

  • 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-23T23:20:01+00:00Added an answer on May 23, 2026 at 11:20 pm

    I’m not sure this would actually be a problem for you because Javascript is single threaded. When the first ajax response comes in and you execute some javascript, that javascript cannot be interupted by the second ajax response as long as it is one continuous thread of execution (no timers or other asynchronous ajax calls as part of it’s processing).

    Let’s run through a scenario:

    1. User clicks button – first ajax call starts.
    2. User clicks button – second ajax call starts.
    3. First ajax call finishes and the completion code execution starts for what to do with the new data.
    4. While code is executing from first ajax call, the second ajax call completes. At this point, the browser puts the second ajax call completion into a queue. It cannot trigger any of your completion code yet because the Javascript engine is still running from the first load.
    5. Now the first load completes it’s execution and code and returns from it’s completion handler.
    6. The browser now goes to it’s queue and finds the next event to process. It finds the completion of the second ajax call and then starts the completion code for that ajax call.

    As you can see from this scenario which has overlapping ajax calls and the second completing in the middle of the processing the first, there still is no conflict because the Javascript engine is single threaded.

    Now, as the other answers have suggested, you make not want this user experience of launching a new request while one is still processing, but they won’t technically conflict with each other. You have several tools you can choose from if you want to prevent overlapping calls:

    • You can prevent starting the second call while the first call is unfinished. You can do this both in the UI and in the actual code.
    • When there are multiple calls outstanding, you can decide to drop/ignore the earlier responses and not process them – waiting only for the last response.
    • When the second call is initiated, you can cancel the first call.
    • You can let the second just replace the first as in the above scenario.

    The first two options require you to keep track of some cross ajax-call state so one ajax call can know whether there are others and act accordingly.

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

Sidebar

Related Questions

I have a question regarding using intptr_t vs. long int . I've observed that
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
I have a question regarding handling errors in a J2EE application. Our current application
I'm writing a small webapp in Grails and I have the following question regarding
Following on from my recent question regarding parsing XML files in Java I have
I have a question about best practices regarding how one should approach storing complex
I have a simple question and wish to hear others' experiences regarding which is
I have question regarding the service and activity. I have one service which calls
Have a question regarding URL and jQuery. Can I specify URL to tell jQuery

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.