2016-12-01 112 views
0

我試圖在Laravel中找到一條郵件路由,並且它給出了一個500錯誤。我嘗試了不同的路線,它的工作原理.. 請注意,我們最近添加了ssl的網站。在Ajax請求期間發生500錯誤

在Chrome瀏覽器開發工具的錯誤消息

jquery.js:4 POST https://murgency.com/saveRequestInfo 500 (Internal Server Error) 

的HTML代碼: -

<div class="form-group text-right"> 
         <a href="" type="button" class="btn-sm-arrowhead" id="dwnBrochure" 
          title="Download Brochure">Download Brochure</a> 
        </div> 

jQuery代碼: -

$('#dwnBrochure').click(function (e) { 

     var text_name = $('#txt_name').val(); 
     var countryCode = $('#countryCode option:selected').text(); 
     var text_number = $('#txt_number').val(); 
     var text_email = $('#txt_email').val(); 
     var package = $('#packagetype').val(); 
     var type = "agingParents"; 
     var url = '/saveRequestInfo'; 

     var data = { 
      name: text_name, 
      email: text_email, 
      countryCode: countryCode, 
      phone: text_number, 
      package: package, 
      type: type 
     }; 

     $.ajaxSetup({ 
      headers: { 
       'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 
      } 
     }); 

     $.ajax({ 
      url: url, 
      data: data, 
      type: 'POST', 
      datatype: 'JSON', 
      success: function (response) { 
       if (response.status === true) { 
        window.location = "https://murgency.com/home-health-plans/senior/brochure-success"; 
       } 
       else { 
        alert('failure'); 
       } 
      }, 
      error: function (response) { 
      } 
     }); 
     e.preventDefault(); 
    }); 

routes.php文件

Route::post('saveRequestInfo', '[email protected]'); 

ServicesController代碼: - 錯誤的

public function saveRequestInfo(Request $request) 
    { 

     $data = $request->input(); 

     $object = new ParseObject("MedicalRequest"); 
     $object->set('name', $data['name']); 
     $object->set('email', $data['email']); 
     $object->set('package', $data['package']); 
     $object->set('phone', $data['countryCode'] . $data['phone']); 
     $object->set('type', $data['type']); 

     try 
     { 
      $object->save(); 
      $status = true; 
     } catch (ParseException $ex) 
     { 
      $status = false; 
     } 

     $this->sendBrochureEmail($data['email'], $data['name']); 

     return Response::json(['status' => $status, 'message' => $data['name']]); 
    } 
+0

你檢查這http://stackoverflow.com/questions/30154489/ajax-post-in-laravel-5-return-error-500-internal-server-error? –

+0

查看您的Laravel /服務器日誌以瞭解500是由什麼引起的。 –

+0

失敗是在響應中..我檢查出來..我會在5-10分鐘確認..請堅持.. –

回答

0

OTHE原因自然是服務器方的錯誤是由於像語法錯誤文件包含有關錯誤或類似的東西的原因。爲了調試,你需要知道PHP產生的錯誤信息,並檢查ajax調用的響應。

如果沒有發現這意味着你的php中的錯誤報告是關閉的。你可以像這樣從php.ini文件打開它

error_reporting = E_ALL 
display_errors = On 

或者也可以通過編碼。像下面一樣;

ini_set('display_startup_errors', 1); 
ini_set('display_errors', 1); 
error_reporting(-1); 

或者可能通過.htaccess文件這樣;

php_flag display_errors  on 
php_value error_reporting  2039 
相關問題