Ich brauche vier Variablen an die Steuerung übergeben, so dass ich tun kann, was ich damit tun wollen, aber ich erhalte eine Fehlermeldung:Laravel Ajax mehrere Variablen an den Controller übergeben?
Missing argument 1 for App\Http\Controllers\ProfileController::getGoogle()
Hier ist mein Controller:
function getGoogle($lat, $lng, $destinationLat, $destinationLng) {
print_r($lat);
print_r($lng);
print_r($destinationLat);
print_r($destinationLng);
}
und Ajax:
function getDirections(lat, lng, destinationLat, destinationLng) {
$.ajax({
url: '/google/',
type: 'post',
data: {
lat: lat,
lng: lng,
destinationLat: destinationLat,
destinationLng: destinationLng
},
dataType: 'json',
success: function() { alert('hello!'); },
error: function() { alert('boo!'); },
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
}
});
}
Route:
Route::post('google/', '[email protected]');
Bitte zeigen Sie Ihre Google-Route. –
Code wurde aktualisiert –
Ich denke, Ihre Route ist falsch, weil Sie 4 Parameter in Ihrem getGoogle() übergeben können –