I have a form on that posts to a hidden iframe. The form's action URL is on a separate domain. I'm seeing a problem in Chrome where t开发者_JAVA技巧he form posts, but no form data is sent.
Here's the setup:
<form action="http://anotherdomain/save" method="post" target="myiframe" id="myform">
<!-- standard form fields here -->
<button type="submit">Submit</button>
</form>
<iframe src="about:blank" name="myiframe" style="display: none;"></iframe>
If the user clicks the button, the form posts as it should into the iframe and all is good. If, however, I introduce jQuery Validation, things stop working in Chrome. I have my validation looking like this:
$("#myform").validate({
// various options set here
submitHandler: function(form) {
form.submit();
// stuff that should happen after the form submits
}
});
In this scenario, form.submit() causes the form to submit without any data being posted, only the headers are sent. The content-length is always 0. This only happens in Chrome, Firefox, IE, Opera all submit fine.
What's more strange is if I have another button on the page and I wire it up with the following code, the form submits properly.
$("myotherbutton").click(function() { $("#myform").submit(); }
I'm at a loss as to why Chrome behaves this way, and if there is a workaround. Any help would be appreciated.
Please ignore this question. It was not a problem with Chrome and event handlers, but rather one related to removing a DOM element before an event was called on it.
精彩评论