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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:23:08+00:00 2026-05-14T00:23:08+00:00

Has anyone had the same experiences with jQuery AJAX and the beforeSend property? Any

  • 0

Has anyone had the same experiences with jQuery AJAX and the beforeSend property? Any advice how to fix this problem?

What I am doing is reading from a database with an AJAX call before I want to send the new data to the database via AJAX (I need to get to the last page of all comments). What happens is that beforeSend retrieves the data WITH the data which should be sent afterwards. Any ideas?

$.ajax({
    type: 'POST', 
    url: '_php/ajax.php',
    dataType:"json",
    async:false, 
    data:{
     action    : "addComment",
     comment_author  : comment_author_val, 
     comment_content  : comment_content_val,
     comment_parent_id :  comment_parent_id_val,
     comment_post_id  : "<?=$_REQUEST["ID"]?>"
    },

beforeSend: function() {
    //WHAT A MESS... 
    if (typeof commentOpen == "undefined") {
     $.get("_php/ajax.php", { action: "getComments", commentPage: '', ID: "<?=$_REQUEST["ID"]?>" },
      function(data){
       $('#comments > ul').html(data);
       return true;
      }
     );
    }
},
  • 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-14T00:23:08+00:00Added an answer on May 14, 2026 at 12:23 am

    Your data retrieval action in beforeSend is asynchronous, meaning $.get() returns immediately and then beforeSend returns immediately. Then the $.ajax() continues execution. At this point, the $.ajax() call is already well underway and has a headstart over the $.get() call. I’m not sure exactly how the two requests are handled concurrently under the covers, but that is the gist of it.

    What you want to do is have $.get() execute synchronously, not asynchonously. That way beforeSend won’t return until the data retrieval completes. To do this, merely add async: false to your $.get() parameter object.

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

Sidebar

Related Questions

Has anyone had any success running two different web servers -- such as Apache
Has anyone had any experience targetting WSH in the way that VBScript , JScript
Has anyone had any experience in building a 'real world' application with the Smart
Has anyone had any experience scaling out SQL Server in a multi reader single
Has anyone had any luck with querying/changing SPNs on a Windows domain? Most of
Has anyone had experience using these two technologies in tandem? What are (if any)
Has anyone had any luck running two instances of the iPhone simulator to test
Has anyone had this unusual(recurring) experience before? I'm trying to check out the project
Has anyone had a chance to dig into how F# Units of Measure work?
Has anyone had success automating testing directly on embedded hardware? Specifically, I am thinking

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.