javascript - setTimeOut function not working as expected -



javascript - setTimeOut function not working as expected -

i having hard time settimeout function .let me show code first.

here code :-

function submitform(loginurl, username, password) { seek { loc = new string(window.location); document.forms.frm_login.action = junctionurl; document.forms.frm_login.username.value = username; document.forms.frm_login.password.value = password; document.forms.frm_login.submit(); settimeout(gotohomepage,4000); } grab (e) { alert(e.message +"submit form"); } } function gotohomepage() { alert("test"); var url = "test.aspx"; window.location=url; }

but here gotohomepage function not @ triggered after specified 4 seconds.

what doing wrong here.please suggest .

any help appreciated.

thanks

form submission redirecting result page unloading current page. so, timer doesn't tick.

use ajax or set target of form iframe. way, current page doesn't unload , timer ticks executing timeout function.

<form target="form_output"> <!-- other inputs --> </form> <iframe name="form_output"></iframe>

javascript

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -