从ajax获取参数到控制器Laravel

2020-02-17 08:01:43 浏览数 (2)

代码语言:javascript复制
$(document).ready(function () {


            $(document).on('click', '.brnch_clk', function () {
                //alert('ok')
                var branchid = $(this).data('branch');
                $('#txt_branchid').val(branchid);
                alert($(this).data('branch'));

                $.ajax({
                    'url': 'search',
                    'type': 'GET',
                    'data': {id: branchid},

                    success: function(response){ // What to do if we succeed
                        if(data == "success")
                            alert(response);
                    },
                    error: function(response){
                        alert('Error' response);
                    }



                });
            });

        });

route Route::get('search', 'ShowstaffController@search'); 接收变量

代码语言:javascript复制
$request->query('id');

0 人点赞