I am trying to call a second function after a first function is complete with an ajax call. I was doing this previously by calling the second function in the success portion of the first function like so
function1(){
    $.ajax({
       success: function(results)
            function2(results);
    })
}
I am trying to make this more elegant and not tie these functions together. I just started experimenting with $.promise()
I am trying to write code that would look something like this
function1().promise().done(function(results){
    function2(results);
});
function1({
   $.ajax({
       success: function(results){
            return results;
       }
   })
})
I could be going about this the completely wrong way. Any advice would be helpful
 
     
    