Questions about AJAX synchronization

Discussion of the technology underlying the eValid solution.

Questions about AJAX synchronization

Postby JRivera » Thu Oct 30, 2014 8:11 pm

Evening eValid.

I saw this article about AJAX synchronization that says you can do the job in JavaScript?

Is this true?

What is your say on this!
JRivera
 
Posts: 1
Joined: Thu Oct 30, 2014 8:08 pm

Re: Questions about AJAX synchronization

Postby eValid » Fri Oct 31, 2014 9:56 am

JRivera wrote:Evening eValid.

I saw this article about AJAX synchronization that says you can do the job in JavaScript?

Is this true?

What is your say on this!


Thanks for posting on the forum JRivera.

As it turns out, this is quite a subtle issue. For one thing JavaScript is single threaded, meaning that it only occupies a single thread (among the many that the browser can have running in its process). In effect, JavaScript code is executed serially, as described here:

http://javascript.info/tutorial/events-and-timing-depth

That means, that once you start a JavaScript program it will run until it finishes, and the next JavaScript program that is in the queue to be run will start, etc.

Why is JavaScript single-threaded, you ask? It boils down to the way a browser enforces the same-origin policy. See this Wikipedia article:

http://en.wikipedia.org/wiki/Same-origin_policy

Now, all these ideas come together when you think about whether a JavaScript program can do AJAX synchronization. The obvious thing to do is to have a loop with a timeout that waits for some DOM property in the page to arrive at a value, and after that the playback can continue.

The problem is, if you run such a program it will hit the timeout limit because -- drum roll -- JavaScript is single threaded! When your timing loop program is running the other JavaScript that is implementing AJAX is blocked -- because JavaScript is single threaded!

OK, so how does eValid do AJAX synchronization? The answer is, that eValid playback is direct to the browser -- it is NOT done with JavaScript. So in eValid the JavaScript runs just fine all by itself normally, while an eValid command like SyncOnText runs in parallel (in the eValid thread, not in the JavaScript thread).

-- eValid Support
eValid
 
Posts: 2395
Joined: Tue Jan 01, 2008 12:48 pm
Location: USA


Return to Technology

Design Downloaded from free phpBB templates | free website templates | Free Web Buttons