I have a table where each row has a button that triggers AJAX call. Calling the same function but different parameters. The result is displayed in the same row that the call was made from.
The call does svn up so it can take even a minute or so. I can observe that if I initiate new AJAX call before the previous one finishes I loose the result of the call.
Is there any way I can run multiple AJAX calls at the same time and get the results from the call and display them?
- using jQuery
- inside the same browser window
- calling php
HTML code that calls javascript
<button type="button" onclick="update_revision(\'' . $directory . '\',\''.$server_name.'\')" > update </button> Javascript
function update_revision(revision,server_name) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("rev."+revision).value="updated to "+update_to; } } xmlhttp.open("GET","https://"+server_name+"/imacs/radek/svn_update.php?code_base="+revision+"&revision="+update_to+"&t=" + Math.random(),true); xmlhttp.send(); }
xmlhttpso every time the state of any of your XHR objects changes, theonreadystatechangechecks the condition of the last one you created.