简体   繁体   English

Json给301永久移动

[英]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." 在Firefox上,只有在Firefox上它会弹出并给你一个警告“这个网页被重定向到一个新的位置。你想重新发送你输入到新位置的表格。”

I got no form , i use javascript to extract values from textbox 我没有任何形式,我使用javascript从文本框中提取值

I checked on firebug it says PUT /admin/submit-scan/ 301 moved permanently PUT submit-scan 302 Found 我检查了firebug它说PUT / admin / submit-scan / 301永久移动PUT提交扫描302发现

My JS 我的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). 删除尾部斜杠应该可以解决问题(最有可能在Laravel 4.1之前,见下文)。

url: '/admin/submit-scan'

Update 更新

As mentioned in Laravel4 POST unexplained redirect to GET 正如Laravel4 POST中提到的无法解释的重定向到GET

Laravel bootstrap/start.php is calling $app->redirectIfTrailingSlash(); Laravel bootstrap/start.php正在调用$app->redirectIfTrailingSlash(); which seems to be the culprit. 这似乎是罪魁祸首。 This has been changed in Laravel 4.1: 这在Laravel 4.1中已经改变了:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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