Hi,
I am working on a page that concurrently calls 3 (or more) of the same jscript function. I am using a function that is tested and works with multiple concurrent ajax requests (found on the web, it works because I am now facing this new problem).
The html is just this
<div id="1"> <script> ajax2(); </script> </div>
<div id="2"> <script> ajax2(); </script> </div>
<div id="3"> <script> ajax2(); </script> </div>
As you can see, the html requests 3 simultaneous calls to an identical function.
The ajax2() jscript function has this line to request an open of a file
xhrObj.open("GET", "../testa.php",true);
The problem is that sometimes the file is not available to be opened because of too many simultaneous requests, and the program gives a
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:/xampp/htdocs/test/testa.php'
How do I handle this error and substitute the open file request so that it would open another file (ie testb.php)?
I tried to handle the substitution with the method of using testb.php and testc.php as substitutions for testa.php if testa.php is not available.
var x = xhrObj.open("GET", "../testa.php",true);
if (!x) { var y = xhrObj.open("GET", "../testb.php",true);
if (!y) { xhrObj.open("GET", "../testc.php",true);}
}
but the code does not work. The syntax is wrong, because it gives the same error and the warnings show that testa.php is always the file that is not available.
What is the correct syntax for checking whether the xhrobj.open is OK, and if not, open another file?
TIA