I have a script which run at the top of the page to get the location of the client and in that script is also a javascipt ajax request.
var xhr = new XMLHttpRequest();
var data = county.short_name;
xhr.open('POST', '/getlocation');
xhr.setRequestHeader('X-CSRF-TOKEN', document.querySelector("meta[name='csrf-token']").getAttribute("content"));
xhr.onreadystatechange = function() {//Call a function when the state changes.
if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
//window.location = '/home';
}
}
xhr.send(data);
In controller i want to catch the value from request - but it does not work:
public function getLocation(Request $request){
dd($request->data);
}
What i am doing wrong? I am using laravel 5.4
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2u9OQiJ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire