By default, calls to the web service asynchronously with AJAX is performed (third parameter equal to true)

When the response from the web service is available, an event is triggered and can execute any function javascript to use the data collected.

You can also ejectuar synchronously, but not recommended.

This JAVASCRIPT code activates listening to see if the server response arrives, and when activated, verify that the answer is correct and executes the code we want to make with that data.

xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } }

Click Here