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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:05:04+00:00 2026-06-01T12:05:04+00:00

Short version: Looking for a method to wait for an Asynch XHR request or

  • 0

Short version:
Looking for a method to wait for an Asynch XHR request or a way to get Synch XHR working in Safari.

Much longer version:
I’m working on a web service that uses various external data sources mashed together. I am using a Javacript front-end which makes AJAX/XHR calls to my PHP server code. There’s no cross-site issues as the client only requests data from my server (the server makes the external data requests).

I’m using a synchronous XHR request as I have some post-load processing (sorting, filtering, etc) to do on the data before it is presented on screen.

This all works fine on IE, FF and Opera, but seems to be a problem to Safari (I haven’t tried Chrome yet).

Using Firebug for Safari on my Windows machine I can see the server calling beng made and then it fails after a time above 10 seconds. On my iPad the message is slightly beter as it says: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous mode.

A bit of research indicates that Safari will timeout after 10 seconds in synch mode. There appears to be a timeout function which timeout function you can use to extend this (with a max limit for Safari of 60 seconds). Unfortunately I can’t get this to work.

I’m now wondering what people would suggest as the best way of working around this through changes to the client Javacript code.

The two options I’m thinking are (i) find a working example of a synch XHR timeout that Safari browsers will honour; or (ii) having some sort of wrapper around an asynch XHR call so that the post-load processing waits for the load first.

I’m not a particulalry experienced Javascript hacker, but I have setup a fair amount on this project. I haven’t used JQuery or any other frameworks and would prefer to keep with raw JS just to avoid having to learn the additional syntax. [You may see from my previous posts I tried using JQM and Spry in the past, but both proved to be the wrong choices, at least at this stage and have since been ditched for now].

I get the feeling a callback may be the right wait-for-asych option, but I’m not sure how this works or how you would code it.

This is just a prototype at this stage, so dirty hacks are acceptable. A full re-write is already on the cards for later on once I have proven functionality.

Appreciate peoples thoughts and advice on this.

Regards,
Pete.

  • 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-01T12:05:05+00:00Added an answer on June 1, 2026 at 12:05 pm

    Generally, you’ll want to stick to asynchronous requests, as they’re non-blocking. And with them, you’ll want to use a callback — or, simply, a function that is setup to be called later.

    You can set the callback with the onreadystatechange property of an XMLHttpRequest:

    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {   // DONE
            if (xhr.status === 200) { // OK
                handleSuccess(xhr);
            } else {
                handleError(xhr);
            }
        }
    };
    

    As the property name suggests, it will be called as the value of readyState changes, where a value of 4 means the request has completed (successful or not).

    You’d then handle your sorting, filtering, etc. within another function — in this example, handleSuccess.

    You can also benefit from using any of a number of existing libraries — e.g., jQuery (1.6 or later for this snippet):

    $.get('/web/service/request')
        .done(function (result) {
            // sorting, filtering, etc
        })
        .fail(function (xhr) {
            // error notification, etc.
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short version: I have a similar setup to StackOverflow. Users get Achievements. I have
Short version: I'm trying to determine the best way to track what the user
Short Version: Is there a/what is the suggested way to return error details to
Long story short, the .Net ConfigurationManager.GetSection method skips duplicates, and I'm looking for a
Short version: Is there an attractive, simple way of implementing a language-specific url structure,
Short version : echo testing | vim - | grep good This doesn't work
Short version: Is it easy/feasible/possible to program modal window in Flash (AS3)? Is there
Short version: How can I map two columns from table A and B if
SHORT VERSION OF QUESTION: So basically my question is: How can I set the
Short Version: What are the chances that a site's various sub-pages' page-ranks will suffer

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.