Any way to simulate a *synchronous* XDomainRequest (XDR) request Any way to simulate a *synchronous* XDomainRequest (XDR) request json json

Any way to simulate a *synchronous* XDomainRequest (XDR) request


asynchron is asynchron. If you want to do something after the request is finished u have to put it into the xdr.onload function.

There is no "wait" function in javascript. You could build one and do a setTimeout loop to check the variable all x-miliseconds. But that would not help u in this case (and its very ugly). In your case you can use the onerror and ontimeout to check if the server had a problem, and the onload to check if the city is in the json.

xdr.onload = function() {json = jQuery.parseJSON(xdr.responseText);//check if a city is loaded, go on if true};xdr.onerror = function() {alert('Unable to determine the location of the city and state you entered');//do whatever u wanna do if something went wrongxdr.ontimeout = function() {alert('404 Server');//do whatever u wanna do if something went wrong}

i hope this helps you find the way (and by the way, the use of async requests is a much a better way then block the hole javascript/browser ;)

The jQuery doc says:

As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success()