diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 28dadde94..ae87a458e 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -972,24 +972,21 @@ class ModuleHandler extends Handler // Handle iframe form submissions. if(isset($_POST['_rx_ajax_form']) && starts_with('_rx_temp_iframe_', $_POST['_rx_ajax_form'])) { - $script = ''; - if(!$oModule->toBool()) + $data = []; + if ($this->error) { - $script .= sprintf('window.parent.alert(%s);', json_encode($oModule->getMessage())); + $data['error'] = -1; + $data['message'] = lang($this->error); } else { - if($oModule->getMessage() && $oModule->getMessage() !== 'success') - { - $script .= sprintf('window.parent.rhymix_alert(%s, %s);', json_encode($oModule->getMessage()), json_encode($oModule->getRedirectUrl())); - } - if($oModule->getRedirectUrl()) - { - $script .= sprintf('window.parent.redirect(%s);', json_encode($oModule->getRedirectUrl())); - } + $data['error'] = $oModule->error; + $data['message'] = lang($oModule->message); } + $data = array_merge($data, $oModule->getVariables()); + ob_end_clean(); - echo sprintf('', $script, json_encode($_POST['_rx_ajax_form'])); + echo sprintf('', json_encode(strval($_POST['_rx_ajax_form'])), json_encode($data)); return; } diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index 6c939f708..1d2e8b5d0 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -351,7 +351,16 @@ $('').appendTo($(document.body)); form.attr('method', 'POST').attr('enctype', 'multipart/form-data').attr('target', iframe_id); form.find('input[name=_rx_ajax_form]').val(iframe_id); - window.remove_iframe = function(iframe_id) { + window.XE.handleIframeResponse = function(iframe_id, data) { + if (data.error) { + if (callback_error) { + callback_error(data); + } else { + alert(data.message); + } + } else { + callback_success(data); + } if (iframe_id.match(/^_rx_temp_iframe_[0-9]+$/)) { $('iframe#' + iframe_id).remove(); }