-1

I'm using Laravel 5.6, and the following is my view (leads/show.blade.php):

<form method="post" id="student_form">
    {{csrf_field()}}
    <span id="form_output"></span>
    <div class="form-group">
        <label>Choose Group for Your Lead</label>
        <select name="group_id" id="group_id" class="form-control">
            @foreach($groups as $group)
            <option value="{{$group->id}}"> {{$group->name}}</option>
            @endforeach
        </select>
        <input type="hidden" name="customer_id" id="customer_id" value="{{$lead->id}}">
    </div>
    <div class="modal-footer">
        <input type="hidden" name="student_id" id="student_id" value="" />
        <input type="hidden" name="button_action" id="button_action" value="insert" />
        <input type="submit" name="submit" id="action" value="Add" class="btn btn-info" />
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
</form>

and the route is :

Route::post('leads/savegroup', 'LeadsController@savegroup')->name('leads.savegroup');

Please help me to find the error in this route.

DsRaj
  • 2,288
  • 1
  • 16
  • 26
Abd AM
  • 119
  • 3
  • 14

1 Answers1

2

Add <form method="post" id="student_form" action="{{ url('/leads/savegroup') }}">

to your code.As you are posting data to empty route .You need to define some action.

Mayuri Pansuriya
  • 934
  • 6
  • 13
  • Yes, it is working with me, but I need to use Ajax .. the problem in Ajax as I notice it now .. So I need to use the form without action .. The problem in Ajax now .. Can u check it in this link : https://stackoverflow.com/questions/51760101/cant-find-the-error-in-my-route-in-laravel-with-ajax?noredirect=1#comment90479263_51760101 – Abd AM Aug 09 '18 at 06:32
  • Can you just try to remove `method="post"` from your form – Mayuri Pansuriya Aug 09 '18 at 06:33
  • yes it is working with me after removed the method="post", but i need to use Ajax, when i check the console, I found this error: Failed to load resource: net::ERR_BLOCKED_BY_CLIENT – Abd AM Aug 09 '18 at 06:37
  • The problem in 'route' as well, while i used the same example with different route .. and it is working with me ... but when I update it for this page, the error was shown – Abd AM Aug 09 '18 at 06:47
  • Can you check that the route name is not duplicate for like GET or other method already defined in your route file – Mayuri Pansuriya Aug 09 '18 at 06:48