Problem with Webkit form submission
I'm running into a problem with the jQuery submit() function that seems to be one of a) a jQuery bug, b) a Webkit bug, or c) something stupid on my part.
Given the following code, the form gets submitted with one click using Firefox and IE, but requires a second click on Webkit-based browsers (Chrome and Safari):
- <html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function submit_form() {
$('div').html('Submit was pressed.');
$('form').attr('action', 'http://www.google.com').submit();
}
</script>
</head>
<body>
<div></div>
<form action="javascript:submit_form()">
<input type="submit">
</form>
</body>
</html>
Firefox and IE both submit the form immediately. In Safari, I see the <div> change, but have to press the submit button a second time in order to submit the form.
(The end goal is some AJAX logic to determine where the form gets submitted.)
Should this work? Is there another way to accomplish this?