решил сделать модальное окно botstrap создал такую кнопу Код (PHP): <a data-toggle="modal" data-target="#myModal" onclick="send('id={$email.id}')"> такой mail.php код Код (PHP): <?php define("CLIENTAREA", true); require "init.php"; if (isset($_SESSION['uid'])) { require "includes/smarty/Smarty.class.php"; $smarty = new Smarty(); $smarty->template_dir = "templates/" . $whmcs->get_sys_tpl_name() . "/"; $smarty->compile_dir = $templates_compiledir; $smarty->assign("template", $whmcs->get_sys_tpl_name()); $smarty->assign("LANG", $_LANG); $smarty->assign("companyname", $CONFIG['CompanyName']); $smarty->assign("logo", $CONFIG['SystemURL']); $id = $whmcs->get_req_var("id"); $result = select_query("tblemails", "", array("id" => $id, "userid" => $_SESSION['uid'])); $data = mysql_fetch_array($result); $date = $data['date']; $subject = $data['subject']; $message = $data['message']; $date = fromMySQLDate($date, "time"); $smarty->assign("date", $date); $smarty->assign("subject", $subject); $smarty->assign("message", $message); $template_output = $smarty->fetch("mail.tpl"); echo $template_output; return 1; } ?> и само модальное окно main.tpl Код (PHP): <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>{$LANG.clientareaemails} - {$companyname}</title> </head> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="false">×</span></button> <h4 class="modal-title" id="myModalLabel"> <p><strong>Пользователь:</strong></p> <p><strong>Тема:</strong> {$companyname} {$logo} - {$subject}</p> <p><strong>от кого:</strong></p> <p><strong>Кому:</strong></p> </h4> </div> <div class="modal-body">{$message}</div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Закрыть</button> </div> </div> </div> </div> </html> затем написал AJAX чтоб по ajax передавались переменные php Код (PHP): function send(dataToSend){ $.ajax({ type: "GET", url: "mail.php?"+dataToSend, data: $("#myModal").serialize(), success: function(response) { console.log(response); //просто так, для отладки $("#subject").html(response[0]); $("#message").html(response[1]); $("#myModalLabel").show(); } }); } console.log(response); выдает все что должно вывести, а в модальное окно это все не выводится, что надо ещё дописать? Добавлено спустя 4 минуты 40 секунд: пытался как то в php дописать Код (PHP): $smarty_arr['subject'] = $subject; $smarty_arr['message'] = $message; $smarty->assign("smarty_arr", $smarty_arr); //смысл в том, чтобы не делать assign каждый раз, а только один передав сразу массив данных $template_output = $smarty->fetch("mail.tpl"); echo $template_output; echo $array[$subject, $message]; return 1;
Всё правильно работает, $("#subject").html(response[0]); $("#message").html(response[1]); тегов с id subject и message нету