mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 04:52:14 +09:00
Support success and error callbacks in rx_ajax forms
This commit is contained in:
parent
2385a62b95
commit
0f6c1edc68
1 changed files with 15 additions and 1 deletions
|
|
@ -369,7 +369,21 @@
|
||||||
if (form.attr('target')) {
|
if (form.attr('target')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Prevent page refresh.
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
// Get success and error callback functions.
|
||||||
|
var callback_success = form.data('callback-success');
|
||||||
|
if (callback_success && window[callback_success] && $.isFunction(window[callback_success])) {
|
||||||
|
callback_success = window[callback_success];
|
||||||
|
} else {
|
||||||
|
callback_success = null;
|
||||||
|
}
|
||||||
|
var callback_error = form.data('callback-error');
|
||||||
|
if (callback_error && window[callback_error] && $.isFunction(window[callback_error])) {
|
||||||
|
callback_error = window[callback_error];
|
||||||
|
} else {
|
||||||
|
callback_error = null;
|
||||||
|
}
|
||||||
// If the form has file uploads, use a hidden iframe to submit. Otherwise use exec_json.
|
// If the form has file uploads, use a hidden iframe to submit. Otherwise use exec_json.
|
||||||
var has_files = form.find('input[type=file][name!=Filedata]').size();
|
var has_files = form.find('input[type=file][name!=Filedata]').size();
|
||||||
if (has_files) {
|
if (has_files) {
|
||||||
|
|
@ -388,7 +402,7 @@
|
||||||
}, 1000);
|
}, 1000);
|
||||||
form.submit();
|
form.submit();
|
||||||
} else {
|
} else {
|
||||||
window.exec_json('raw', form.serialize());
|
window.exec_json('raw', form.serialize(), callback_success, callback_error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue