2016-12-01 19 views
0

私はLaravelのポストルートにヒットしようとしていますが、エラーは500です。私は別のルートを試して、それは動作します.. 私たちは最近、サイトにsslを追加したことに注意してください。Ajaxリクエスト中に500エラーが発生しました

クロームのDevツールでエラーメッセージ

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/serverのログで、500の原因を調べてください。 –

+0

エラーが応答しています。私はそれをチェックしています.iは5-10分後に確認します。 –

答えて

0

オット理由は、構文エラーまたはファイルのインクルード関連のエラーまたはそのような何かのような理由のために自然にサーバー側のエラーです。これをデバッグするには、PHPが生成したエラーメッセージと、ajax呼び出しの応答を調べる必要があるかどうかを知る必要があります。

あなたのPHPでのエラー報告がオフであることを意味するものが見つからない場合。

error_reporting = E_ALL 
display_errors = On 

などのphp.iniファイルからオンにすることもできますし、コーディングを介して行うこともできます。次のように。

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 
関連する問題