alphasil Posted March 5, 2015 Share Posted March 5, 2015 Hi I'm using this framework to my project and i'm having some issues I have created a funciont sendEmail() to use after validate that my query has been inserted.but when i have this function my main page doesn't close the dialog, if i remove this function tha page close the dialog I don't undertand that This is php <?php require 'PHPMailerAutoload.php'; require_once('class.phpmailer.php'); include("class.smtp.php"); include 'conn.php'; header("Content-Type: text/html;charset=utf-8"); mysql_query("SET NAMES 'utf8'"); $idUser = filter_input(INPUT_POST, 'userid'); $email = filter_input(INPUT_POST, 'email'); $cargo = filter_input(INPUT_POST, 'cargo'); $atividade = filter_input(INPUT_POST, 'nome'); $data = filter_input(INPUT_POST, 'data'); $hora = filter_input(INPUT_POST, 'hora'); $local = filter_input(INPUT_POST, 'local'); $inter = filter_input(INPUT_POST, 'inter'); $notas = filter_input(INPUT_POST, 'notas'); $newDate = date("Y-m-d", strtotime($data)); $cargoId = mysql_query("SELECT idcargo FROM pae_cargo WHERE cargo= '$cargo'"); $cargoRow = mysql_fetch_row($cargoId)or die(mysql_error()); $cargoNome = $cargoRow[0]; if ($cargoNome != null) { $sql = "Insert into `pae_atividades`(idutilizador, idcargo,atividade,data,hora,local,inter,notas) values('$idUser','$cargoNome', '$atividade','$newDate','$hora','$local','$inter','$notas')"; } $result = mysql_query($sql); if ($result) { sendEmail(); echo json_encode(array( 'success' => true, 'message' => 'Atividade Registada com Sucesso')); } else { echo json_encode(array('errorMsg' => 'Erro...nada foi registado.')); } function sendEmail() { $email = filter_input(INPUT_POST, 'email'); $atividade = filter_input(INPUT_POST, 'nome'); $data = filter_input(INPUT_POST, 'data'); $hora = filter_input(INPUT_POST, 'hora'); $local = filter_input(INPUT_POST, 'local'); $inter = filter_input(INPUT_POST, 'inter'); $notas = filter_input(INPUT_POST, 'notas'); $newDate = date("Y-m-d", strtotime($data)); $vaiEmail = "A sua atividade foi registada com sucesso\n\nAtividade: $atividade\n\nData: $newDate\n\nHora: $hora\n\nLocal: $local\n\nIntervenientes: $inter\n\nNotas: $notas\n\nObrigado"; $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPDebug = 1; $mail->Debugoutput = 'html'; $mail->Mailer = "smtp"; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->SMTPKeepAlive = true; $mail->SMTPAuth = true; $mail->Username = "[email protected]"; $mail->Password = "xxxx"; $mail->setFrom('[email protected]', 'PAAD - Atividades'); $mail->addReplyTo('[email protected]', 'PAAD - Atividades'); $mail->addAddress($email); $mail->Subject = 'Registo de nova atividade'; $mail->Body = $vaiEmail; if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } And this is my javascript function atividadeNova() { $('#fm').form('submit', { url: 'nova_atividade.php', onSubmit: function () { return $(this).form('validate'); }, success: function (result) { var result = eval('(' + result + ')'); if (result.errorMsg) { console.log(result.errorMsg), $.messager.show({ title: 'EBSPMA Atividades - Erro', msg: result.errorMsg }); } else { $.messager.show({ title: 'EBSPMA Atividades - Sucesso', msg: result.message, timeout: 2000, showType: 'slide', style: { right: '', top: document.body.scrollTop + document.documentElement.scrollTop, bottom: '', zIndex: $.fn.window.defaults.zIndex++ } }); $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); } If i use the function i receive the email but the javascript seems not responding I'm sending an example to see...with function sendEmail(); the record has been inserted into the database but that window dialog doesn't close. What's wrong? Thanks Link to comment https://forums.phpfreaks.com/topic/295129-jquery-easyui-phpmailer-gmail-error/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.