I'm not sure I follow exactly how deferred, promises and $.when()
work. I've read through https://api.jquery.com/jquery.when/, but I'm curious about whether a function with an ajax call can be used inside of $.when()
.
I see this example on the documentation:
$.when( $.ajax( "test.aspx" ) ).then(function( data, textStatus, jqXHR ) {
alert( jqXHR.status ); // Alerts 200
});
Is this also an acceptable method?
$.when( $.ajax( anotherFunction() ) ).done(
//on completion of the ajax call inside "anotherFunction()" do something here.
);
anotherFunction(){$.ajax...do some ajax stuff here.}
The specific case I'm looking at is loading a list of available dashboard, then once the list is populated on the front end, capture a specific dashboard out of the list and run a load function for it.
I'm finding that it does not break and will run (maybe?) but I don't know if it's the proper way to code it out or if it's just not working and not breaking at the same time.
Thanks for any advice and expertise on this!
-Jeff