Laravel AJAX PUT update request only works in localhost

1.9k Views Asked by At

I can't figure out why this block of code only works on my localhost, in my production server the requests goes through and $request->input() returns an empty array but in my localhost it works perfectly fine. Both on version php7. Any thoughts ?

var formData = new FormData($('#postSliderFrm')[0]);

if(imagePicked)
    formData.append('file',imagePicked);

formData.append('_method', 'put');

$.ajax({
    type: 'PUT',
    url: '{{route('dashboard.admin.sliders.update', $slider->id)}}',
    data: formData,
    processData: false,
    contentType: false,
    success: function(data) {

    },
    error: function(data) {

    }
});

I've also tried adding

{!! method_field('put') !!}

inside my form but still no luck

1

There are 1 best solutions below

4
On

Method not allowed when PUT used over AJAX for Laravel resource: Take a look at that, it might be better to use GET or more commonly POST to handle this, do you specifically NEED to use PUT?