I have a $.post which using Fiddler I can see always posts successfully but my success function is never fired.
A successful post to the url returns a 1 or failure returns a 0, on each occasion I have tested it returns the expected value of 1 so I'm at a lost as to what I'm doing wrong?
if ($('#mycheckbox').prop('checked')) {
$.post('/base/MailingList/Subscribe/',
{
listId: $('#mycheckbox').val(),
name: $('#subscriber-name').val(),
email: $("#subscriber-email").val()
},
function(response) {
console.log(response);
});
}
Stick another function as a final callback. That function will run in the failure case.
The way jquery recommends doing it is this:
var jqxhr = $.post( "example.php", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "finished" );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With