title: Automatic Ajax request to controller
body: <p>How can I send some data via ajax to controller without click event. I mean when user lands on HOME page, i want to obtain his current latitude and longitude and I was able to get his/her current coordinates.But my problem is that I am unable to send this latitude and longitude to particular route,so that i can search nearest hotels based on his current coordinates.</p>
  
  <p>my code:</p>
  
  <pre><code>&lt;script&gt;
  if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function (position) {
          console.log(position);
          var lat = position.coords.latitude;//this gives latitude
          var lng = position.coords.longitude;//this gives longitude
  
          $.ajax({
              url:'http://localhost:8000/coordinates',
              type:'get',
              data:{latitude:lat,longitude:lng},
  
  
              success:function(data)
              {
                 alert('success');
              }
  
          });
      });
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>My route</p>
  
  <pre><code>Route::get('/coordinates', 'SearchController@getCoordinate');
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function getCoordinate(Request $request){
      return $request-&gt;latitude;// i am getting nothing here. i expect to get 
     latitude of user
  }
  </code></pre>
  
  <p>How can i obtain this coordinates in <code>getCoordinate</code> function of my controller when user visit the website.</p>