title: How to use ajax in laravel 5.3
body: <p>I am new to Laravel and am using Laravel 5.3. I want to make a text field where it will automatically suggest some data and when I select a data it will add it to an array. I want to send that array to a controller for further use. For this the </p>
  
  <blockquote>
    <p>view file is as follows:</p>
  </blockquote>
  
  <pre><code>&lt;head&gt;
      &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          $(document).ready(function() {
              var members = {!!  json_encode($member)  !!};
              console.log(members);
              var arr = [];
              $("#tags").autocomplete({
                  source: members,
                  select: function (event, ui) {
                      arr.push(ui);
                      console.log(arr);
                  }
              });
              $("#submit").click(function(event){
                  $.ajax({
                      type: "POST",
                      url: '/storeresearch',
                      data: {selectedMembers: arr},
                      success: function( msg ) {
                          console.log(msg);
                      }
                  });
              });
          });
          &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form id="hu" action="/storeresearch" method="POST"&gt;
      {!! csrf_field() !!}
      &lt;label&gt;Research Author&lt;/label&gt;
      &lt;input type="text" id="tags" name="researchsupervisor_1" value=""&gt;
      &lt;input type="submit" name="submit" id="submit" class="btn btn-primary" value="Add"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <blockquote>
    <p>My Controller file is as follows:</p>
  </blockquote>
  
  <pre><code>public function store(Request $request){
          if($request-&gt;ajax())
          {
              $mem = $request-&gt;all();
              return response()-&gt;json($mem,200) ;
          }
          else{
              return "not found";
          } 
  </code></pre>
  
  <blockquote>
    <p>And web.php is as followings:</p>
  </blockquote>
  
  <pre><code>Route::post('/storeresearch','ResearchController@store');
  </code></pre>
  
  <p>But it seems that there is no ajax call happening. In the controller it always enters the else section. What is the problem can anyone help?  </p>