简体   繁体   中英

Json giving 301 Moved Permanently

on Firefox, only on firefox it will popup and give you a warning "This web page is being redirected to a new location. Would you like to resend the for form you have typed to the new location."

I got no form , i use javascript to extract values from textbox

I checked on firebug it says PUT /admin/submit-scan/ 301 moved permanently PUT submit-scan 302 Found

My JS

function submitGoods(){
    var registeredNo = $('input[name=registeredno]').val();
    var weight = $('input[name=weight]').val();
        $.ajax({
            type: 'PUT',
            url: '/admin/submit-scan/',
            data: {
                registeredNo: registeredNo,
                weight: weight,
                _token: csrfToken
            },
            dataType: 'json'
        }).done(function(data){

                data = $.parseJSON(data);
            });

}

My Route

Route::put('submit-scan', 'Controllers\Admin\DashboardController@putUpdateSubmitScan');

My controller

 public function putUpdateSubmitScan()
    {
        if (Request::ajax())
        {
            return Response::json(array('success' => 1, 'data' => "test"));
        }
    }

Any idea what went wrong?

Removing the trailing slash should do the trick (most probably prior to Laravel 4.1, see below).

url: '/admin/submit-scan'

Update

As mentioned in Laravel4 POST unexplained redirect to GET

Laravel bootstrap/start.php is calling $app->redirectIfTrailingSlash(); which seems to be the culprit. This has been changed in Laravel 4.1:

http://laravel.com/docs/upgrade#upgrade-4.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM