title: How to retrieve data using ajax and without going to post page? Laravel 5
body: <p>I'm new to using ajax. For example after field <code>title</code> is filled, I want to search in database for specific data and return more fields based on that input. So far I can only receive my <code>title</code> data in /ajax/post page by pressing get data/post data or submit button. How do I receive my <code>title</code> input and data from <code>Route::post</code> while/after filling <code>title</code>? If I remove <code>Form::model</code> and <code>Form::close()</code> I do get my dummy data from <code>Route::post</code> without page refresh by clicking <code>Post data</code> button, but without title value.</p>
  
  <p>I'm aware that checking <code>title</code> field involves some jQuery/js, but I have no idea how to actually bring that <code>title</code> field into my <code>route</code> to do some database searching and return some data with it.</p>
  
  <p>View:</p>
  
  <pre><code>            {!! Form::model($project = new \App\Project, ['url' =&gt; 'ajax/post', 'method' =&gt; 'post']) !!}
              &lt;!-- pass through the CSRF (cross-site request forgery) token --&gt;
              &lt;meta name="csrf-token" content="&lt;?php echo csrf_token() ?&gt;" /&gt;
  
              &lt;!-- some test buttons --&gt;
              &lt;button id="get"&gt;Get data&lt;/button&gt;
              &lt;button id="post"&gt;Post data&lt;/button&gt;
  
              &lt;div class="form-group padding-top-10"&gt;
                {!! Form::label('title', 'Title') !!}
                {!! Form::text('title', null, ['class' =&gt; 'form-control', 'placeholder' =&gt; 'Title']) !!}
              &lt;/div&gt;
              {!! Form::submit('Submit Button', ['class' =&gt; 'btn btn-primary form-control']) !!}
              {!! Form::close() !!}
  </code></pre>
  
  <p>Ajax script:</p>
  
  <pre><code>&lt;script&gt;
      $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } });
      function onGetClick(event)
      {
          // we're not passing any data with the get route, though you can if you want
          $.get('/ajax/get', onSuccess);
      }
      function onPostClick(event)
      {
          // we're passing data with the post route, as this is more normal
          $.post('/ajax/post', {payload:'hello'}, onSuccess);
      }
      function onSuccess(data, status, xhr)
      {
          console.log(data, status, xhr);
          // JSON is deserialised into an object
          console.log(String(data.value).toUpperCase())
      }
      $('button#get').on('click', onGetClick);
      $('button#post').on('click', onPostClick);
  &lt;/script&gt;
  </code></pre>
  
  <p>And in route:</p>
  
  <pre><code>    Route::get('/ajax/view', ['as' =&gt; 'home', 'uses' =&gt; 'AjaxController@view']);
      Route::get('/ajax/get', function () {
          $data   = array('value' =&gt; 'some get');
          return  Response::json($data);
      });
      Route::post('/ajax/post', function () {
          $data   = array('value' =&gt; 'some data', 'input' =&gt; Request::input());
          return  Response::json($data);
      });
  </code></pre>