Reputation: 1
this is my url value from arduino request_string = "http://127.0.0.1:8000/monitoring/x/?x=1";
i have problem when try to catching the value using url in ajax
$.ajax({
type:'get',
url:'http://127.0.0.1:8000/monitoring/x/',
dataType: "json",
success:function(response){
if (response.data==0) {
var img = document.getElementById("kursi7");
img.src="{{asset('/assets/images/kursi.jpg')}}";
document.getElementById('lokasi'+1).innerHTML=("TIDAK ADA ORANG");
}else {
// location.reload();
var img = document.getElementById("kursi7");
img.src="{{asset('/assets/images/kursi_booked.jpg')}}";
document.getElementById('lokasi'+1).innerHTML=("ADA ORANG");
}
}
});
and processing in php (laravel) i have some error undefined variable x when try to get the data $_GET['x'] from passing value url in arduino
public function data(Request $req, $x)
{
$x=$_GET['x'];
return response()->json($x);
}
i hope someone can help and give me an information abt this. thanks a lot mate
Upvotes: 0
Views: 89
Reputation: 440
For the PHP side of things you should be doing something like this instead:
public function data(Request $request)
{
$x = $request->input('x')
return response()->json($x);
}
As per https://laravel.com/docs/8.x/requests#accessing-the-request
Upvotes: 0