JQuery deferred reject immediately
问题 When using JQuery.Deferred is it OK to invoke reject() directly? Without having invoked a async function? Perhaps I want some kind of test in the beginning of my async function. If the test fails I want to reject immediately. See the first if block below. function doSomethingAsync() { //Test if the ajax call should be invoked var testFailed = true; var dfd = $.Deferred(); //Check if test failed if (testFailed) { var asyncResult = { success: false, data: 'test failed' }; //Is this OK usage of