title: consolidating $.ajax
body: <p>I have several ajax call on my page and I want to consolidate them into one function.</p>
  
  <p>For now I have this type of function in several places:</p>
  
  <pre><code>function AjaxCallOne () {
  
   //do something
  
   $.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: TheURL,
    data: "{'TheData':'" + JsonData + "'}",
    dataType: "json",
    cache: "false",
    success:...
    error:...
   });
  }
  </code></pre>
  
  <p>I want to write a single function that'll be used for all ajax calls like this:</p>
  
  <pre><code>function MyGeneralAjaxCall(TheData, TheURL, TheSuccessFunction, TheErrorFunction) {
    $.ajax({ .... });
  }
  </code></pre>
  
  <p>My question is this: if I do that and the user send two ajax calls, almost simultaneously, to the point where the second ajax call is made before the returning data of the first call comes back, will the success or error functions trigger for the the correct call. I'm worried that the success function that'll be executed won't be for the proper ajax call if the user triggers a second call before the first one is returned.</p>
  
  <p>Thanks.</p>