title: Please, suggest a library to mock ajax requests in a browser
body: <p>I've run into a problem with Ajax lately. I'm working on a frontend of a large application and at some point it calls a service which is being developed by another team. They have some hard performance issues and while they are doing they best t o keep it stable sometimes AJAX call times out or returns an error.</p>
  
  <p>Meanwhile as I work on client-side I need to mock this service somehow. I could have just replace callback function with a modified version with some fake data I wonder if there are any more elegant ways to solve this problem.</p>
  
  <p>I'd like to be able to the following:</p>
  
  <ul>
  <li>Completely stub the call to external service;</li>
  <li>Conditionally mock it: if it returns normally I prefer using the actual data, otherwise fake data is fine.</li>
  <li>Automatically actualize fake data: when a server call returns normally save the data behind the scenes so that it can be used for further executions in case of an error.</li>
  <li>Having an ability to pre-process the data coming to a server before it gets into a callback would also be quite nice.</li>
  </ul>
  
  <p>I can certainly write something like that myself but I'm pretty sure that someone solved this problem already.</p>
  
  <p>I'm using jQuery for AJAX calls so a jQuery-specific solution would work just fine, too.</p>