title: Jquery - Calling a ajax function within ajax function
body: <p>Can I use ajax function withing a ajax function.</p>
  
  <p>In my case there are two ajax calls. First ajax will return some data , If it is successful then the second ajax should be called .</p>
  
  <p>Below is my code snippet,</p>
  
  <pre><code>$.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      async: false,
      url: "my service url here"
      dataType = "json",
  
      //success - 1
      success: function(data) {
  
          //I ll collect the data from service 
          //now the second ajax must run.
          //Because in first call I ll receive some data 
          //That data I going to use in my second call   
          $.ajax({
                  alert('inside ajax-2');
                  type: "GET",
                      contentType: "application/json; charset=utf-8",
                      async: false,
                      url: "my second service URL here",
                      dataType: "json",
  
                      //success - 2
                      success: function(data) {
  
                          //some functionality 
  
                      } //success-2
              } //success-1
          }); //ajax - 2
  }); //ajax - 1 
  </code></pre>
  
  <p>Some more info :
  I had checked chrome dev console and the error I am getting is</p>
  
  <pre><code>//success - 1
  success: function(data) {
     //Error message : Uncaught SyntaxError: Unexpected identifier
  </code></pre>
  
  <p>That was the error message I got.</p>
  
  <p>And yes I cleared the syntactical mistakes and I was getting the same error message.</p>
  
  <pre><code>$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  async: false,
  url: "my service url here",
  dataType : "json"
  
  //success - 1
  success: function(data) {
  
      //I ll collect the data from service 
      //now the second ajax must run.
      //Because in first call I ll receive some data 
      //That data I going to use in my second call   
      $.ajax({
              alert('inside ajax-2');
              type: "GET",
                  contentType: "application/json; charset=utf-8",
                  async: false,
                  url: "my second service URL here",
                  dataType: "json",
  
                  //success - 2
                  success: function(data) {
  
                      //some functionality 
  
                  } //success-2
          } //success-1
      }); //ajax - 2
  }); //ajax - 1 
  </code></pre>
  
  <p>I checked the service URL in RESTClient extension of firefox browser and again yes , there is Jsondata coming from that service. </p>
  
  <p>Any good suggestion will be highly appreciable</p>
  
  <p>Merry Christmas :)</p>