title: Multiple ajax requests writing on same file.
body: <p>In my application, I am using multiple ajax requests which write to an XML file. Ajax requests are fired on certain events(like a div's offsettop being equal to certain value) so their timing cannot be exactly predicted. It is also possible that both requests fire at the same time. My question is, if they both fire at the same time and try to write to the same XML file, do you think it would create a conflict which will not allow the file to be open by two requests. Because, in my case I am getting an error saying :</p>
  
  <p><strong>( ! ) Warning: SimpleXMLElement::asXML(withbabu.xml) [simplexmlelement.asxml]: failed to open stream: Invalid argument</strong> </p>
  
  <p>I know this error comes when the filename is wrong or the file doesnt exist, but in my case the same request is able to run many times the same lines of code and only sometimes, it returns this error. So, I am sure that something is happening behind the scenes. As I am using multiple ajax requests writing to the same file so I thought, this could be the reason for this error. Please provide your answer if you know what could be the solution to this. </p>
  
  <p>The error is coming on this line:</p>
  
  <pre><code>$filename = "with".$SESSION['user'];
  $xml-&gt;asXML($filename.'.xml');       // error shows its line number here. 
  </code></pre>
  
  <p>Just as an introduction, this is similar to a gaming application and is firing multiple ajax requests based on certain events. </p>
  
  <p>Thank you so much for your time to review my question. </p>
  
  <p>Cheers. </p>