I am trying to submit a form with ajax, the form itself is loaded via a ajax event
The following Jquery code works in FF?chrome. In IE, the form submission is not prevented
$("#admin_main").delegate("#create_user_form", "submit", function (event) {
if (event.preventDefault) {
event.preventDefault();
} else {
event.returnValue = false;
}
$.post('create_user', $("#create_user_form").serialize(), function (data) {
$("#admin_main").html(data);
}, "html");
});
Any workarounds?
jQuery normalizes this, you can reliably call
.preventDefault(), like this:Or if you want to completely kill the event,
return false:The reason it’s not an issue to call it is because it’s not a browser-specific event object that you’re dealing with, it’s a jQuery event object that has normalized behavior.