dryl34156 2015-02-06 07:46
浏览 74

通过ajax将数组传递给Laravel路线

I have laravel route defined as below

Route::get('dos',array('as'=>'saveOrder','uses'=>'HomeController@SaveOrder'));

And my ajax request as below

var params = $("#tab_logic :input[name='id[]']").serialize();
//alert(params);

$.ajax({
    url: "dos",
    method: 'GET',
    data: params,
    //dataType:"json",
    success: function( data ) 
    {
        // do nothing
        alert(data);
    }
});

I get an 500 server error when executed. The input field ID[] is an array and I want this array to be sent to laravel route so that I can handle it in controller action with Input::get('id').

  • 写回答

3条回答 默认 最新

  • dongyuqi3808 2015-02-06 09:52
    关注

    by checking the log found out that there was issue in scope query.How do I acheive this using scope query.

    $data = Books::select(DB::raw('count(*) as order_count, subject'))
                    ->whereIn('id',$id)
                    ->groupBy('subject')
                    ->get();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ensp的问题(需要各个路由器命令)
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题