从控制器获取模态中的ajax成功消息

时间:2018-02-19 12:48:14

标签: jquery ajax cakephp-3.x

这是Ajax代码

$('#snd').click(function(){
    var e = $("input[id=mid]").val()
    $.ajax({
        type: "POST",
        dataType:"HTML",
        url:"/mail/";
        data:{'valu': e},
        dataSrc : '',
        success: function(msg) {
            //table.reload();     
            //console.log(msg);
            $("#succModal").modal('show');
            table.ajax.reload();
        },
   });
});

这是模态代码

<div class="modal fade" id="succModal" tabindex="-1" role="dialog" aria-labelledby="succModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="succModalLabel">Customers</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p id="mg"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">OK</button>
            </div>
        </div>
    </div>
</div>

这是控制器代码

try
{
    $mail->send();
    echo 'Message has been sent';
} 
catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}

电子邮件已成功发送。但是没有显示任何消息。模式不随消息一起显示。请帮我。谢谢

0 个答案:

没有答案