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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:13:58+00:00 2026-06-07T00:13:58+00:00

in order to recover data from server I use XMLHttpRequest and my code is

  • 0

in order to recover data from server I use XMLHttpRequest and my code is this (it works fine)

window.onload = function getArtists() {
    xmlhttpLoad=new XMLHttpRequest();           
    xmlhttpLoad.onreadystatechange=function() {
        if (xmlhttpLoad.readyState==4 && xmlhttpLoad.status==200) {
            // put data in an invisible HTML elem           
        }
    }
}

Now I want to use a particular library, but it requires that this data are loaded BEFORE document document.onload is fired. How can I do this? Can I use the code above but block HTML parsing until data are loaded? I mean something like

<head>
    <script>
        // block parsing until data are loaded
        // put data from server in a variable
    </script>
    <script src="newLib.js"></script>
<head>
  • 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-07T00:14:01+00:00Added an answer on June 7, 2026 at 12:14 am

    If you don’t use the load event but just run the code directly, it will start immediately when the script block has been parsed.

    To make the parsing of the next block wait for the AJAX response, you have to make a synchronous request. You do that by supplying false for the third parameter (async) in the open call:

    <head>
      <script type="text/javascript">
    
      xmlhttpLoad=new XMLHttpRequest();
      xmlhttpLoad.onreadystatechange=function() {
        if (xmlhttpLoad.readyState==4 && xmlhttpLoad.status==200) {
            // put data in an invisible HTML elem           
        }
      }
      xmlhttpLoad.open("get", "somepage", false);
    
      </script>
      <script type="text/javascript" src="newLib.js"></script>
    <head>
    

    }

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

Sidebar

Related Questions

What do I need to do in order to recover from a failed SVN
I need to recover XML data from a news provider for a website. In
Order deny,allow deny from all allow from xx.xx.x.xx RewriteRule . - [F] I have
In order to achieve spriting by compass according to the documentation I wrote this:
in order to avoid copy/paste, i can use a unique view for different actions,
I know how to remove files in order to make them impossible to recover.
Order.prototype.selectItem = function(newItem) { ... newItem is the object I want to copy and
I have a mailer script that is looping, processing outgoing emails from my server.
Is there is some way to perform system restore from c# code? Any links\sample?
In order to do not duplicate code, I've decided some time ago, to refactor

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.