submit() runs asyncronously on Chrome/Safari

K

Kevin N

Hello,

It seems that the form submit() function runs asyncronously on Chrome
and Safari (Windows version); for example if I have a window created
with open() containing a form, MyForm, and a button with onclick
handler MyFormSubmit() as follows

function MyFormSubmit() {
// validate form data here


// submit the form and close the popup window
document.MyForm.submit();
window.close();
}

Now this works fine on Firefox 3.x, IE (6,7,8), Opera 9.x: the data is
sent to the server and the popup window closes. On Chrome and Safari,
it does not. The popup window is closed with nothing being submitted
to the server. It seems this is an issue with submit running
asyncronously on Chrome. For example if I insert code between the
submit() and close() that will take a few milliseconds to run, or add
a setTimeout to call the close(), Chrome and Safari will work fine.

This is not urgent, since we do not intend to support those two
browsers anyway, but it would be nice to know the proper way to code
this in a way that will work on all the browsers I mentioned (besides
the two hacks I mentioned).
 
J

Jorge

Kevin said:
Hello,

It seems that the form submit() function runs asyncronously on Chrome
and Safari (Windows version); for example if I have a window created
with open() containing a form, MyForm, and a button with onclick
handler MyFormSubmit() as follows

function MyFormSubmit() {
// validate form data here


// submit the form and close the popup window
document.MyForm.submit();
window.close();
}

Now this works fine on Firefox 3.x, IE (6,7,8), Opera 9.x: the data is
sent to the server and the popup window closes. On Chrome and Safari,
it does not. The popup window is closed with nothing being submitted
to the server. It seems this is an issue with submit running
asyncronously on Chrome. For example if I insert code between the
submit() and close() that will take a few milliseconds to run, or add
a setTimeout to call the close(), Chrome and Safari will work fine.

This is not urgent, since we do not intend to support those two
browsers anyway, but it would be nice to know the proper way to code
this in a way that will work on all the browsers I mentioned (besides
the two hacks I mentioned).

remove the window.close() in the calling window's <script> and put it in
a <script> in the form's response .html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top