Have been working on this for 2 days and can't figure out what is causing this to fail in IE (v11) and Firefox. Works fine in Chrome.
Read a lot of questions on here that covered caching issues with multiple Ajax calls, particularly with IE, but I don't believe that's the issue. This code is actually one of two forms on the page. Both are submitted via jQuery, when a "Submit All" button is clicked. I disabled the first form, though, and the second still doesn't function properly.
Here's the JS/Ajax code for the faulty form submission:
$("body").on( "submit", ".update-guest-email", function(event) {
event.preventDefault();
var form = $(this);
if( form.find('input[name="email"]').val() == "" ) {
return;
}
if (!formChecker(form)){
return;
}
var dataString = {
action : 'update_guest_party',
data : form.serializeArray()
}
$.ajax({
cache: false,
type: "post",
url: ajaxurl, // This is the WP AJAX handler.
data: dataString,
beforeSend: function() {
form.find('input').prop('disabled', true);
},
success: function(response){ //so, if data is retrieved, store it in response
if (response.data >= 1){
form.append('<div class="center confirmed"><span class="dashicons dashicons-yes"></span></div>');
form.removeClass();
} else {
form.find('input').prop('disabled', false);
$(".errors").html("That's weird; it didn't go through. You can try again or <a href='mailto:email@gmail.com'>send us an email</a>.")
$('.errors').slideDown(250);
}
} // Close success response.
}); // Close AJAX.
}); // End form-submit.
Again, that functions as expected in Chrome. Firebug shows POST data correctly:
action update_guest_party
data[0][name] email
data[0][value] brundeezy@gmail.com
data[1][name] table
data[1][value] dw_wedding_mgr_guests
data[2][name] id
data[2][value] 149
But then the response is just a '0' (zero). Per Chrome, the response should look like this:
{"success":true,"data":1}
Any help is greatly appreciated! I also have this on a live server, if it would be helpful to see it in production.
Aucun commentaire:
Enregistrer un commentaire