Sorry, my comment was not correct because I was not looking close enough at the structure. I'm pretty sure it would work if modified though.
I just setup the following route:
Route::put('{cpe_mac}/device/{device_mac}/rate/update', [ 'as'=> 'device.rate.update', 'uses' => 'DeviceController@updateRate']);
I added the javascript to the view:
$.ajax({
url: '{{ route('device.rate.update', [$cpe_mac, $device_mac], true) }}',
type: 'PUT',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: {
some: 'test'
},
success: function(data) {
console.log(data);
},
error: function(xhr) {
console.log(xhr);
}
});
I'm passing true
as the 3rd argument so it builds a URL with an absolute path. I think it's a bit cleaner than trying to prepent env("APP_URL")
.
The result on the page was:
$.ajax({
url: 'http://myapp.local/000D6766F2F6/device/080027E2FC7D/rate/update',
type: 'PUT',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: {
some: 'test'
},
success: function(data) {
console.log(data);
},
error: function(xhr) {
console.log(xhr);
}
});