title: jquery statement showing syntax error when written in ajax success where framework used is laravel
body: <p>Here is my ajax code writtem in laravel framework for posting comment data. But i am getting syntax error as - </p>
  
  <p>ErrorException
  Parse error: syntax error, unexpected 'Comment' (T_STRING), expecting ',' or ')' </p>
  
  <p>for  my view file.</p>
  
  <p>As per my observation any jquery statement written inside success box giving me error.
  i am using latest version on jquery - 3.3.1.min and laravel 5.4 version.</p>
  
  <p>Please support.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(document).ready(function() {
  
          $("#save-comment").click(function() {
  
              var token = $('meta[name="csrf-token"]').attr('content');
              var comment = $('textarea#commentContent').val();
              var postId = "&lt;?php echo $postId; ?&gt;";
  
              if (comment) {
                  $.ajax({
                      type: "POST",
                      url: "{{ url('/ajax/postcomment) }}",
                      data: { "_token" : token, "commentContent" : comment, "postId" : postId },
                      success: function(d) {
  
                          $("#notify-box").animate({ opacity: 1 }, 2000);
                          $("#notify").text('Comment Saved successfully.');
  
                          setTimeout(function(){
                              $('#notify-box').animate({ opacity : 0 }, 200);
                          }, 6000);
  
                      },
                      error: function(XMLHttpRequest, textStatus, errorThrown) {
                          $("#notify-box").animate({ opacity: 1 }, 2000);
  
                          $("#notify").text(errorThrown);
  
                          setTimeout(function(){
                              $('#notify-box').animate({ opacity : 0 }, 200);
                          }, 6000);
                      }
                  });
              } else{
  
                  $("#notify-box").animate({ opacity: 1 }, 2000);
  
                  $('#notify').text('Add a Reply to save.');
  
                  setTimeout(function(){
                      $('#notify-box').animate({ opacity : 0 }, 200);
                  }, 6000);
  
              }
  
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Notify box is just to display notifications, code here</p>
  
  <pre><code>&lt;div class="notify-box" id="notify-box"&gt;
      &lt;div class="notify-icon"&gt;&lt;i class="fa fa-info-circle" aria-hidden="true"&gt;&lt;/i&gt;&lt;/div&gt;
      &lt;div class="notify-msg"&gt;
          &lt;h4 class=""&gt;Message.!&lt;/h4&gt;
          &lt;p id="notify"&gt;something special done&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>for now view page in not getting rendered and showing error.</p>
  
  <p>laravel web routes</p>
  
  <pre><code>Route::group(['prefix' =&gt; 'ajax', 'middleware' =&gt; ['auth:customer']], function () {
      if(Request::ajax()){
          //  Single post page for comments
          Route::post('/postreply', 'Blog\BlogAjaxController@ajaxPostReply');
          Route::get('/postreply', 'Blog\BlogAjaxController@ajaxGetPostReply');
          Route::post('/postcomment', 'Blog\BlogAjaxController@ajaxPostComment');
      }
  
  });
  </code></pre>
  
  <p>Here is my laravel controller</p>
  
  <pre><code>public function ajaxPostComment(Request $request)
  
  {
      $this-&gt;validate($request, [
          'comment' =&gt; 'required',
      ]);
  
  $blogcomment = new Blogcomment();
  
  $blogcomment-&gt;commentContent = $request-&gt;input('commentContent');
  $blogcomment-&gt;postId = $request-&gt;input('postId');
  $blogcomment-&gt;customerId = '1';     //  Auth::guard('customer')-&gt;id();
  $blogcomment-&gt;commentStatus = 'Pending';
  $blogcomment-&gt;commentType = 'Comment';
  $blogcomment-&gt;commentFlag = 'Unread';
  $blogcomment-&gt;like = '0';
  $blogcomment-&gt;dislike = '0';
  
  $blogcomment-&gt;save();
  return response()-&gt;json([
      'status' =&gt; 'Success',
      'message' =&gt; 'Your Comment Saved Successfully.'
  ], 201);
  </code></pre>
  
  <p>}</p>