I have a strange situation going on with ajax callbacks.
Call A works fine (I can see the server calls in the right place), and the done callback is fired correctly.
Call B call works fine (I can see the server calls in the right place), but then A's done callback is fired!
Here's the code: A:
$(document).ready(function () {
$('#beta_signup_form').submit(function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
url: $(this).attr('action'), //submits it to the given url of the form
data: valuesToSubmit,
dataType: "JSON", // you want a difference between normal and ajax-calls, and json is standard
type: 'POST'
}).done(function(json){
console.log("in the beta signup form success function!!!!");
})
.fail(function () {
console.log("--------> beta signup modal callback error");
});
return false; // prevents normal behaviour
});
});
and code B:
$(document).ready(function () {
$('#twitter_sign_up').submit(function() {
var valuesToSubmit = $(this).serialize();
$.ajax({
url: $(this).attr('action'), //submits it to the given url of the form
data: valuesToSubmit,
dataType: "JSON", // you want a difference between normal and ajax-calls, and json is standard
type: 'POST'
}).done(function(json) {
console.log("in success for modal B...");
}).fail(function () {
console.log("--------> modal B callback error");
});
return false; // prevents normal behaviour
});
});
What's going on here???
OH man... I just figured it out.
So I had:
<div id="twitter_sign_up">
<form id="beta_signup_form" ...>
...
</form>
</div>
My fault for copying html!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.