title: JavaScript promise in recursive function
body: <p>I have a function in my application that must execute multiple times for pagination, however after the first time, resolve never executes again. 
  Am I missing something? </p>
  
  <pre><code>function start(){
      $.when(myrequest()).done(function(result){
           console.log(result);
      })
  }
  
  function myrequest(myurl){
      //NOTE this is just an example but the idea is the same. 
      return new Promise(function(resolve, reject){
           $.ajax({
                url: myurl,
                method: "GET",
                contentType: "application/json",
                headers:{
                     Authorization: key
                },
                success: function(response) {
                   if (response.currenturl !== response.lasturl) {
                        myurl = response.nexturl;
                        //Do stuff with data here as well to create a list. 
                        myrequest(myurl);
                        //RESOLVES JUST FINE
                        resolve("test");
                   }else{
                        //DOESN'T RESOLVE
                        resolve("test");
                   }
                },
                error: function(response){
                     reject("error");
                }
           })
      })
  }
  </code></pre>