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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:05:10+00:00 2026-05-11T06:05:10+00:00

I have a php / mysql / jquery web app that makes 13 ajax

  • 0

I have a php / mysql / jquery web app that makes 13 ajax queries to various APIs and stores the result in a database table. To each result I assign a score and when all the results have completed I want to display a ‘total score’.

My problem is knowing when all the ajax queries have completed and all the results are in and ready to be tallied.

Here’s the existing workflow:

  1. User enters data in the query box and hits submit.
  2. Page reloads and inserts a ‘scan id’ into a ‘scan_index’ table.
  3. Page then executes a jquery $.get function for each of 13 queries ( all queries use the same javascript function to perform their work ).
  4. As each result is returned, the result is inserted into a ‘scans’ table using the previously inserted ‘scan id’ to allow association with the proper scan. The result is also displayed to the user along with that result’s score.

At this point what I would do is retrieve all results in the scans table using the scan_id value, and total up the score and display that to the user.

But my problem is knowing when to kick off the query to retrieve all the totals. Any given query could take up to 10 seconds ( my predefined timeout value ) before completing ( or failing ), but they usually take only about 3 seconds max to complete.

So, without knowing when a query will complete, how can I tell when all queries have completed?

  • 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. 2026-05-11T06:05:10+00:00Added an answer on May 11, 2026 at 6:05 am

    It sounds like the key piece of information you’re missing is the callback functionality of $.get. You can specify a function as the second or third argument which will fire when the request has completed

    $.get('http://example.com/data', {'foo':'bar'}, function(resonseData){     //code here will be called when the ajax call has completed }) 

    So you’ll want to setup a counter variable somewhere that gets incremented by one once for each request that’s made, and then in the callback will decrement this value by one.

    Then, after you’ve made the final get request, setup a watcher using setInterval that will check periodically (once a second, say) to see if the counter is zero. If it is, you’re done with all your requests. You could probably add this check to the $.get callback itself, but that seems like it might be susceptible to timing issues.

    That’s the basic solution, but this could easily be abstracted out into a more robust/elegant queuing solution.

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

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Perhaps use a sort of cache of whether or not… May 11, 2026 at 8:52 pm
  • Editorial Team
    Editorial Team added an answer I'd add parens so clarify what's going on -- ie.… May 11, 2026 at 8:52 pm
  • Editorial Team
    Editorial Team added an answer I firmly espouse the simplicity / refactor-as-needed approach. In this… May 11, 2026 at 8:52 pm

Related Questions

I know I'll get a thousand Depends on what you're trying to do answers,
Over the years most web developers will have built an arsenal of tools or
I have made a chat script using php, mysql and jquery. It uses json
I am trying to send a php script some content to be stored in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.