I am catching the form submission with jquery.
This submit handler works in all browsers except internet explorer where it just does the submit.
How can I fix it?
$('#editForm').live('submit', function() {
var data = [];
var finalForm = $(this).serializeArray();
var differences = 0;
for (var i in initialForm) {
if (!objectsAreSame(initialForm[i], finalForm[i])) {
data[differences] = finalForm[i];
differences++;
}
}
console.log('diff: ', differences);
if (differences > 0) {
$.ajax({
url: site_url + 'ajax/contact',
type: 'POST',
data: {
id: finalForm[0].value,
method: 'editContact',
data: JSON.stringify(data)
},
success: function(data) {
console.log(data);
$('#contact' + finalForm[0].value).hide("drop", {direction: 'up'}, 500, function() {
$('#contact' + finalForm[0].value).replaceWith(data);
$('#contact' + finalForm[0].value).show("drop", {direction: 'up'}, 500, function() {
$(document).trigger('close.facebox');
});
});
return false;
}
});
}
return false;
});
looks like its not even wiring up the submit handler…
doing a straight off return false does nothing…
First of all your code is not neat enough to read; read this I4 ways to better jQuery coding
Anyway below are some hints
console.log()statementsreturnstatement locationif(..){ }else{ }statement instead ofif(...){ }aloneAnd finally, I think it should be written this way; check where the first return statement is