Я привел конкретный пример - неявный вызов функции.
<script>
$('#popup-form-callme').popup();
$(document).on('click', '#callbacktop', function (e) {
e.preventDefault();
$('#popup-form-callme').popup('show');
title = $('title').context;
$('#target_callme').val(title.title);
$('#url_callme').val(title.URL);
});
function callMe(task){
form = $('#modal-form-'+task).serializeArray();//console.log(form);
$.ajax({url:"<?php echo $action ?>",type:'post',data:{form:form},success: function(data){alert(data);$('#popup-form-'+task).popup('hide');}})
}
</script>
<?php
class ControllerInformationCallMe extends Controller
{
private $error = array();
public function index()
{
$this->load->language('extension/module/callme');
if($this->request->server['REQUEST_METHOD'] == 'POST')
{
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'),ENT_QUOTES,'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setReplyTo($this->config->get('config_email'));
$data = array();
$data['from'] = $this->config->get('config_email');
$data['to'] = $this->config->get('config_email');
$data['date'] = gmdate("M d Y H:i:s", time());
$data['text_from'] = $this->language->get('text_from');
$data['text_to'] = $this->language->get('text_to');
$data['text_date'] = $this->language->get('text_date');
$params = $this->request->post['form'];
foreach ($params as $param)
{
switch ($param['name'])
{
case 'task':
$data['message_type'] = $this->language->get('text_'.$param['value'].'_please');
$data['text_callme_new'] = $this->language->get('text_'.$param['value'].'_new');
$mail->setSubject(html_entity_decode($this->language->get('text_'.$param['value'].'_please'),ENT_QUOTES,'UTF-8'));
break;
case 'name':
$data['customer'] = $param['value'];
$data['customer_name'] = $this->language->get('customer_name');
$mail->setSender(html_entity_decode($param['value'],ENT_QUOTES,'UTF-8'));
break;
case 'city':
$data['city'] = $param['value'];
$data['customer_city'] = $this->language->get('customer_city');
break;
case 'phone':
$data['phone'] = $param['value'];
$data['customer_phone'] = $this->language->get('customer_phone');
break;
case 'sumname':
$data['sumname'] = $param['value'];
$data['customer_sumname'] = $this->language->get('customer_sumname');
break;
case 'email':
$data['email'] = $param['value'];
$data['customer_email'] = $this->language->get('customer_email');
break;
case 'target':
$data['target'] = $param['value'];
break;
case 'url':
$data['url'] = $param['value'];
break;
}
}
//$this->log_write($data);
$body = $this->load->view('information/callme',$data);
$mail->setHtml(html_entity_decode($body,ENT_QUOTES,'UTF-8'));/*$this->log_write($mail);*/
$mail->send();
echo $this->language->get('text_success'); exit;
}
}
private function log_write($message)
{
$handle = fopen('test.log','a');
fwrite($handle,print_r($message,true)."\n");
fclose($handle);
}
}
PS. Немного не то, но пример хороший. Есть 3 формы, но обработчик один. И это реальный рабочий пример - на сайте https://orimak.com.ua/