jquery - How to call three function within one function in javascript each function should be called after finishing first -


how call 3 function within 1 function in javascript each function should called after finishing first function receive value user..

javascript code:

function abc(){     var ans  = ask(); /// contain html custom confirm button     if(ans == true)     {         do_action();     }     else     {         refuse_action()     } } 

actually want create own javascript confirm dialog using designing in html.

i have create 2 button in name yes or no

i want call do_action function if click on yes or refuse_action if click on no button.

thanks in advance.

what looking $.deferred() in jquery. in order work, functions have return promise.

without going detail, general structure you're looking for:

function showdialog() {     var ret = $.deferred();      // render confirm dialog, , show     // 'ok'-button needs call ret.resolve();     // call ret.reject() when user clicks 'cancel'.      return ret.promise(); } 

the calling function has following:

function callingfunction() {     var x = showdialog();      x.done(function() {         // put code executed when user clicks 'ok' in dialog.     });      x.fail(function() {         // put code executed when user clicks 'cancel' in dialog.         // can omit hooking .fail() function up, if don't need anything.     }); } 

for more information, take closer @ description of idea behind $.deferred(), , $.deferred api.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -