How to perform a sync ajax call without using jquery?
Clarification: because there is a need to load a remote JSON resource before any of remote js scripts are executed, and then continue page loading.
How to perform a sync ajax call without using jquery?
Clarification: because there is a need to load a remote JSON resource before any of remote js scripts are executed, and then continue page loading.
Yes you can:
var request = new XMLHttpRequest();
request.open('GET', '/bar/foo.txt', false); // `false` makes the request synchronous
request.send(null);
if (request.status === 200) {
console.log(request.responseText);
}
This question has been answered, I believe, here on how to do a non-ajax call: STACKOVERFLOW and here is how to make in synchronous (where I got this answer from) MOZILLA