How to send a variable from JS to my Laravel Controller

前端 未结 1 1877
旧巷少年郎
旧巷少年郎 2021-01-29 10:38

I\'m sorry. I have researched for several hours, several and I still do not reach success with this.

Let me explain:

I\'m on the route /events/1, so

1条回答
  •  孤街浪徒
    2021-01-29 10:57

    So, yes, you're getting the event ID here:

    var event_id = $('#event_id').val();
    

    But you're not doing anything with that variable. If you never use a variable you've assigned, that's a major indication that you have a problem in your code. Some programming languages will even refuse to compile because of it.

    Pass the event ID in the query string of your GET request, just like you're doing with day ID:

    $.get('/hour?day_id=' + day_id + '&event_id=' + event_id, function(data){
    

    Then retrieve it the same way from the Input facade:

    $event_id = Input::get('event_id');
    

    0 讨论(0)
提交回复
热议问题