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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:03:23+00:00 2026-06-11T05:03:23+00:00

so I have this: $(‘.something’).click(function(){ $(‘body’).html(”); $.ajax({ url: ‘someurl’, dataType: ‘json’, async: false, success:

  • 0

so I have this:

$('.something').click(function(){
          $('body').html('');

          $.ajax({
            url: 'someurl',
            dataType: 'json',
            async: false,
            success: function(data){
              //do stuff
              alert('yo');
            }
          });

          return false;   
});

in Firefox, body would become blank BEFORE the ‘yo’ alert correctly…But then in Chrome, body would only become blank after the ajax succeeds and the ‘yo’ alert even though the $(‘body’).html(”) call is performed before the ajax….this is due to the async setting which is set to false…if it’s true it’ll work properly in chrome as well

is there a way to have the $(‘body’).html() call gets called BEFORE the ajax call properly in Chrome while keeping the async flag set to false?

Also it would be preferrable to not have to set timeout

  • 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-11T05:03:25+00:00Added an answer on June 11, 2026 at 5:03 am

    Are you sure that you have seen that the page becomes blank before the AJAX call with that code? That should not happen in any browser.

    The browser window is not updated at all while a script is running, so the synchronous call will block all updates.

    To make the browser update before the AJAX call, use setTimeout, that will return the control to the browser before the request is sent:

    $('.something').click(function(){
      $('body').html('');
    
      window.setTimeout(function() {
    
        $.ajax({
          url: 'someurl',
          dataType: 'json',
          async: false,
          success: function(data){
            //do stuff
            alert('yo');
          }
        });
    
      }, 0);
    
      return false;   
    });
    

    Note: This will of course mean that you can’t use the result from the request in the return value of the function, if that was the intention with the synchronous call. If you need the event handler to be synchronous, you can’t update the browser before the AJAX request.

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

Sidebar

Related Questions

I have this function // add history paths and save data function AddPath( strTag,
i have this youtube url http://www.youtube.com/watch?v=9N51Etoikfw&feature=youtube_gdata i need to remove the feature parameter and
I have this class class Validator implements iValidation{ protected $_fields, $_errors; public function __construct($fields){
I have this html <div class=p-box> <div class=p-img></div> <h3>title</h3> <div class=txt>some txt</div> </div> with
have this html: <div id=editable contentEditable=true > <span contentEditable=false >Text to delete</span> </div> need
Have this <a href=#>something</a> and then I handle it in Jquery code. This displays
I have this function: public static string Join(this IEnumerable<string> strings, string separator) { return
Have this code: <sj:head compressed=false jqueryui=true jquerytheme=custom/> <s:url id=link action=ABC namespace=/DEF escapeAmp=false/> <sj:a openDialog=_dialog
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in

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.