문제

There is a rather simple html application.

Changing text field will cause a submit, follow by a redraw. Pressing button will cause a submit, too.

When changing a field and leave it by pressing a button, the browser run into a conflict. The browser starts one submit, aborts it and do the next submit. The result is unreliable.

Is there a simple solution to get one submit with button and field without switching to some AJAX approach (say GWT)?

도움이 되었습니까?

해결책

You could cancel any other event handler when starting to submit the form. This is similar to disabling a submit after clicking it, to prevent the form being submitted twice by impatient users.

다른 팁

You can send a flag that will tell if submit function has called once, if submit already called then don't call submit for this user.

OR you can disable the submit button as soon as call the function from text field change, in this way user will not be able to click on the submit button.

Might help you

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top