PDA

View Full Version : form.submit -- window.location weirdness


jnylund
09-11-2009, 04:43 PM
Hi, I have a form and an on click event below, I noticed that sometimes the window.location is being called before the submit happens, and the form never gets submitted, I fixed the code by returning false after doing the form submit, but im trying to understand how this could happen. Is form.submit asynchronous and allows window.location to take over, why does it work sometimes and not other times? I noticed when I debug in firebug, it always work (probably because submit has time to work)

thanks
Joel


function mySave(n){
if(clicked =="n")
document.journal.submit();

return true;
}

javascript:clicked='n';prevl='f'; if(mySave(this.id))window.location='Main.htm?page=5&from=p';

A1ien51
09-12-2009, 02:28 PM
You have a race condition, you should not rely on that. Your serverside code should be doing the redirect when the response comes back.

Eric