weixin_33688840 2015-10-10 19:58 采纳率: 0%
浏览 16

Laravel Ajax发布异常

I have a select box. And i'm redirecting clients via select box. When they select they are redirecting.

Before i started to write code with laravel my system was working. After laravel i have a problem with this matter.

$('#parent_products').change(function(){
            productid = $(this).val();

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $.ajax({
                type: 'POST',
                url: '{{ route('redirectVariant') }}',
                data: {
                    productid : productid,
                    _method   : 'PATCH'
                },
                error: function(jqXHR, exception) {
                    alert('Hata 
' + jqXHR.responseText);
                },
                success: function (data) {
                    window.location.replace(data);
                }
            });
        });

I'm getting this error.

MethodNotAllowedHttpException in RouteCollection.php line 219:

This is my route

Route::group(['prefix' => 'ajax'], function () {
        Route::post('product/redirect_variant', [
            'uses' =>'AjaxController@redirectVariant',
            'as'   => 'redirectVariant',
        ]);
    });

Here is my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class AjaxController extends Controller
{
    public function redirectVariant(Request $request){
        dd(Request::all());
    }
}

What is the problem ?

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题