I am using jQuery to execute form submission via ajax request. I use
form.submit(function() {
if( success ) {
return true;
}
validate();
return false;
}
If the request is successful, I want to either continue submitting the form or the user callback. Therefore, if the user callback is undefined, I will submit the form when the form validation is successful (from my validation function).
config = {
successCallback: function() {
success = true;
form.submit();
}
};
validate = function() {
$.ajax(
...
success: function(data) {
config.successCallback();
}
);
};
The ajax success callback will call config.successCallback (), and if it is never canceled by the user, it will go to the normal view of the form. I tried using the instance variable (success) to make sure that "return true" goes to the default form view.
, . , "return false", , , . ( ).
- . , , , , , ajax , ajax .