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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:23:38+00:00 2026-06-18T01:23:38+00:00

I am experiencing two issues with my jQuery record-inserting process, and I am hoping

  • 0

I am experiencing two issues with my jQuery record-inserting process, and I am hoping that this wonderful SO community can help me to solve at least one of those issues. These are the issues:

Issue 1 – Intermittent server delay

The first issue relates to the fact that my Ubuntu 10.04 server seems to exhibit intermittent, 4.5 second delays when doing a POST of data to the mySQL database. Most POST commands are executed within a normal amount of milliseconds, but when a delay occurs, it always seems to be for approximately 4.5 seconds. This is not a busy, public server so it shouldn’t be a matter of server load being the problem. These short videos demonstrate what I am trying to explain:

Video 1
Video 2

I have posted a question on serverfault and am awaiting some input from that forum which is probably more appropriate for this Issue 1.

Issue 2 – Timing of jQuery POST and GET Methods

The real issue that I am trying to resolve is to prevent the call to GET before all of the calls to POST have completed. Currently, I have implemented $.when.apply to delay the sending of GET. Here is the code for that:

function(){
  $.when.apply(undefined, InsertTheAPPs()).done(function (){
    $.ajax({
      url: sURL + "fileappeal/send_apps_email",
      success: function() {
        var m = $.msg("my message",
        {header:'my header', live:10000});
        setTimeout(function(){
          if(m)m.setBody('...my other message.');
        },3000);
        setTimeout(function(){
          if(m)m.close(function(){
              window.location.replace(sURL+'client/view');
          });
        },6000);
        $('#ajaxShield').fadeOut(1000);
      },
      error: function(){
          $.msg("error message",
          {header:'error header', live:10000});
      }
    });
  });
}

My problem arises due to the delay described above in Issue 1. The GET method is being called after all of the POST methods have begun, but I need the GET method to wait until all of the POST methods have ended. This is the issue that I need assistance with. Basically, what is happening is happening wrong here is that my confirmation email is being sent before all of the records have been completely inserted into the mySQL database.

Here is the code for the jQuery $.each loop. This is the code that needs to not only begin, but must end before the ajax call to fileappeal/send_apps_email above:

function InsertTheAPPs(){
  $('input[name=c_maybe].c_box').each(function(){
    var jqxhrs = [];
    if($(this).prop('checked')){
      var rn = $(this).prop('value');
      jqxhrs.push(
        $.ajax({
          url: sURL + 'fileappeal/insert_app',
          type:"POST",
          dataType: 'text',
          data: {'rn': rn},
          error: function(data) {console.log('Error:'+rn+'_'+data);}
        })
      )
    return jqxhrs;
    }
  });
}

Anyone have any suggestions for how I can workaround the server delay issue and prevent the call to the GET before all of the POST methods have completed? 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-06-18T01:23:39+00:00Added an answer on June 18, 2026 at 1:23 am

    There’s a small problem with your post. After you resolve it, this post should help you finish out your code: jQuery Deferred – waiting for multiple AJAX requests to finish

    You’re returning inside the .each but the function itself doesn’t return anything. So your delay is not being given the array of ajax calls to wait for. And also, since your jqhrs is defined inside the each, the scope is per iteration over each c_box. Your method should look like this:

    function InsertTheAPPs(){
        var jqxhrs = [];
    
        $('input[name=c_maybe].c_box').each(function(){         
            if($(this).prop('checked')){ 
                var rn = $(this).prop('value'); 
                jqxhrs.push(
                    $.ajax({
                        url: sURL + 'fileappeal/insert_app',
                        type:"POST",
                        dataType: 'text',
                        data: {'rn': rn},
                        error: function(data) {console.log('Error:'+rn+'_'+data);}
                    })
                )
            }
        });
    
        return jqxhrs;
    } 
    

    You can also make your code easier. Since you just want to know if something is checked you can use the jquery pseudo class filter :checked such as:

    function InsertTheAPPs(){
        var jqxhrs = [];
    
        $('input[name=c_maybe].c_box').filter(':checked').each(function(){         
            var rn = $(this).prop('value'); 
            jqxhrs.push(
                $.ajax({
                    url: sURL + 'fileappeal/insert_app',
                    type:"POST",
                    dataType: 'text',
                    data: {'rn': rn},
                    error: function(data) {console.log('Error:'+rn+'_'+data);}
                })
            )
        });
    
        return jqxhrs;
    } 
    

    You could combine the filter on :checked into the main filter such as $('input[name=c_maybe].c_box:checked') but I left it in long form to really demonstrate what was going on.

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

Sidebar

Related Questions

I am experiencing several issues that I can't understand from the first glances. The
I'm experiencing a strange PHP session issue. Can someone tell me if that's how
I'm experiencing two intermittent problems with Silverlight 3.0, running on Windows 7 with Visual
I am experiencing a little pain on Android. I have two activities, one is
I'm experimenting with using jQuery toggle to move between two functions. The results so
Experiencing jquery in rails through .js.erb templates; but completely puzzled by a simple problem
I am experimenting on this color control panel where a user can change the
I'm experiencing a weird issue in Google-Chrome that when one tab is open with
I'm experiencing some behavior I did not expect. I have a synchronous procedure that
I'm experiencing an issue which has two possible solutions. I am unsure which solution

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.