2016-11-02 66 views
0

我想打電話給郵件功能在jQuery的頁面laravel 5.3.I有郵件路由器名稱爲「歡迎郵件」電話郵件功能

Route::get('welcome-mail','[email protected]'); 

Controller 
public function welcomeMail() 
{ 
    $to_email = '[email protected]'; 
    Mail::to($to_email)->send(new Reminder); 
    //return "E-mail has been sent Successfully"; 
} 

mail/Remainder.php 
public function build() 
{ 
    return $this->from('[email protected]') 
       ->view('email.welcome'); 
} 

view/email/welcome.blade.php 
<html> 
<body> 
    <h3>Hi,</h3> 
    <p>Test mail Travel approval</p> 
</body> 
</html> 

我要調用此函數json響應或json url

if(approve_id=='Y'){ 
    var status = 'approved'; 
    $.ajax({ 
    url: 'request-status', 
    type: 'GET', 
    data: {'id':user_id,'status':status,'comment':comment}, 
    dataType: 'JSON', 
    success: function(data, textStatus, jqXHR){ 
    //alert(data); 
    url: 'welcome-mail' //want to call like this 
    $(".table-responsive").load(location.href + " .table-responsive"); 
    }, 
    error: function(jqXHR, textStatus, errorThrown){ 
// alert('errror'); 

    }, 
}); 
    } 

回答

0

請在控制器請求狀態中處理您的歡迎郵件以代替ajax響應。

或者

$.ajax({ 
    type: "POST", 
    url: "/request-status", 
    data: {'id':user_id,'status':status,'comment':comment}, 
    success: function (data) { SuccessCall(data); }, 
    error: function (xhr, status, error) { alert(error); } 
     }); 


function SuccessCall(data){ 
$.ajax({ 
type: "POST", 
url: "welcome-mail", 
success: function (data) { //Success message }, 
error: function (xhr, status, error) { alert(error); } 
}); 
} 
+0

在我的控制器我嘗試作爲//路線::獲得( '歡迎郵件', 'travelerHome @ welcomeMail'); – user3386779