Hi there Joe. You would basically need to do something like this, taken from the User module:
if ($this->is_ajax_request()) { $this->send_ajax_response(array( 'success' => TRUE, 'heading' => lang('user_successful_submission'), 'message' => lang('password_changed'), 'content' => lang('password_changed') )); exit(); } return ee()->output->show_message(array( 'title' => ee()->lang->line('success'), 'heading' => ee()->lang->line('success'), 'link' => array( $return, ee()->lang->line('return') ), 'content' => ee()->lang->line('password_changed') ));
Ideally the show_user_error method would handle that in the EE core, but it isn’t there…. yet.
CSM handles ajax responses in this way:
if( $this->EE->input->is_ajax_request() AND ( !isset($settings['enable_ajax']) OR ( isset($settings['enable_ajax']) AND $settings['enable_ajax'] == 'y') ) ) { if(isset($data['type']) AND $data['type'] === false) { $data['success'] = true; } else { $data['success'] = false; }
$this->EE->output->send_ajax_response($data); exit; }
Basically don’t just resort to the show_user_error method, test for an ajax request first, then use send_ajax_response or show_user_error depending on the case.
|