jquery - Settimeout() not working synchronusly -
i have page submitbutton.when submit button clicked,i need show dialog box notification messages 2 seconds.after 2 seconds,i need redirect page location.
settimeout(function(){ $('#wrapper_dialog').dialog('close'); }, 2000); //after popup closes,i need redirect page window.location = "?load=parents/communication"; when this,dialog comes , page asynchronously leading next page.
settimeout(function(){ $('#wrapper_dialog').dialog('close');}, 2000).then(function(){ window.location = "?load=parents/communication"; }); this not working.
settimeout doesn't return promise, returns number; there's no then function available on it.
just put location assignment after call close dialog, within settimeout callback:
settimeout(function(){ $('#wrapper_dialog').dialog('close'); window.location = "?load=parents/communication"; }, 2000); or if have animation on dialog close, put location assignment in close event of dialog:
settimeout(function(){ $('#wrapper_dialog').dialog('close').on("dialogclose", function() { window.location = "?load=parents/communication"; }); }, 2000); that wait change location until animation complete.
Comments
Post a Comment