本文介绍了杰森(Json)给予301永久移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firefox上,仅在firefox上会弹出并警告您:此网页已被重定向到新位置.您想重新发送输入到新位置的for表单."

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."

我没有表格,我使用javascript从文本框中提取值

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

我检查了萤火虫,上面写着PUT/admin/submit-scan/301永久移动PUT提交扫描302找到

I checked on firebug it saysPUT /admin/submit-scan/ 301 moved permanentlyPUT submit-scan 302 Found

我的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);
            });

}

我的路线

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

我的控制器

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

知道发生了什么事吗?

推荐答案

删除斜杠应该可以解决问题(很可能在Laravel 4.1之前,请参见下文).

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

url: '/admin/submit-scan'

更新

Laravel4 POST无法解释的重定向到GET所述

Laravel bootstrap/start.php正在调用$app->redirectIfTrailingSlash();,这似乎是罪魁祸首.在Laravel 4.1中已更改:

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

这篇关于杰森(Json)给予301永久移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 00:33