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.

my code:

```
<script>
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');
            }

        });
    });
}

</script>

```

My route

```
Route::get('/coordinates', 'SearchController@getCoordinate');

```

Controller:

```
public function getCoordinate(Request $request){
    return $request->latitude;// i am getting nothing here. i expect to get 
   latitude of user
}

```

How can i obtain this coordinates in `getCoordinate` function of my controller when user visit the website.