duanqinqian5299 2017-07-30 09:38
浏览 69

错误Laravel输入:获取路由Web

I have to ask something again. Here is my java script code

<script>
    $('#spiele').on('change', function(e){
        console.log(e);

        var spielID = e.target.value;

        //ajax
        $.get('/spieler-table?spielID=' + spielID, function(data){

            //success data
            console.log(data);
        });
    });
</script>

Everything works fine. But in my route web there I getting an error.

jquery-3.2.1.min.js:4 GET http://localhost:8000/spieler-table?spielID=3 500 (Internal Server Error)

Here it is...

Route::get('/spieler-table', function(){
    $testvar = Input::get('spielID');
    echo $testvar;
});

I think it is because of the var spielID which comes from my javascript code. Because the i get into the Route get and the php echo works fine with an easy string output. But when I try to Input the spielID into tester. I getting the error. Im using the laravel framework

  • 写回答

1条回答 默认 最新

  • douqi3064 2017-07-30 19:34
    关注

    change your script little bit :

    <script>
            $('#spiele').on('change', function(e){
    
    
                var spielID = $('#spiele').val();
    
                //ajax
                $.get('/spieler-table?spielID=' + spielID, function(data){
    
                    //success data
                    console.log(data);
                });
            });
        </script>
    

    change your route code like this :

    Route::get('/spieler-table', function(Request $request){
            $testvar = $request->spielID;
            return $testvar;
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统