Posts

Showing posts from July 18, 2013
Difference between asynchronous (AJAX) and synchronous request? Now-a-days, this is a very common question that been asked in all most every basic interview – What is the main strength of AJAX? Or why and when should we use AJAX in web application? And the most common answer is – “AJAX does not refresh or reload the whole page”. But, the more perfect answer is – “AJAX is an asynchronous technology where others request are synchronous.” So, what is the difference? In a word, a program does not wait for response after requesting an asynchronous call whereas synchronous does so. Here is a simple example – function check() { var a=0; a = getStatus(“getstatus.php?id=5”); if(a==1) { alert(“active”); } else { alert(“not active”); } } Here getStatus() function sends a AJAX request to the server with “getstatus.php?id=5” url and the php file decides (from database may be) the status and output/response as 1 or 0. But, this function will n