mercredi 29 août 2018

laravel csrf in javascript return The page has expired due to inactivity. Please refresh and try again

I have a code for the delete data loop in a table. this can be used, and works.

            
                            @foreach ($datasiswa as $a)

                                <a class="btn btn-info btn-sm" data-toggle="modal" data-target="#aktifMagang"><i class="fa fa-check"></i> Aktifkan Magang</a>
                                <!-------- start Modal --->
                                <div id="aktifMagang" class="modal fade" role="dialog">
                                  <div class="modal-dialog">
                                        <!-- Modal content-->
                                        <div class="modal-content">
                                          <div class="modal-header bg-aqua">
                                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                <h4 class="modal-title">Daftarkan Magang</h4>
                                          </div>
                                          <div class="modal-body">
                                                <form action="" method="POST" class="form-horizontal">
                                                   Aktifkan <strong></strong> sebagai peserta magang ?
                                                  <input type="hidden" name="siswa_id" value="">

                                          </div>
                                          <div class="modal-footer">
                                                <button type="submit" class="btn btn-primary">Aktifkan</button>
                                                <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                                          </div>
                                        </div>
                                        </form>
                                  </div>
                                </div>
                                @endforeach

                        


but the results will make every data a modal. if I have 100 data then there should be 100 modal.

Is there a way to make each loop use a single modal?

searching ... and i found this .

            
                            @foreach ($datasiswa as $a)

                                <a class="btn btn-info btn-sm"data-toggle="modal" data-target="#aktifMagang" data-siswaid=""><i class="fa fa-check"></i> Aktifkan Magang</a><br /> 
                                @endforeach

                        


then

    
                    <div id="aktifMagang" class="modal fade" role="dialog">
                                <div class="modal-dialog">
                                  <!-- Modal content-->
                                  <div class="modal-content">
                                        <div class="modal-header bg-aqua">
                                          <button type="button" class="close" data-dismiss="modal">&times;</button>
                                          <h4 class="modal-title">Daftarkan Magang</h4>
                                        </div>
                                        <div class="modal-body">
                                          <form action="" method="POST" class="form-horizontal">
                                                
                                                Aktifkan <strong class="namasiswa"></strong> sebagai peserta magang ?
                                                <input type="hidden" name="siswa_id" value="">
                                        
                                        </div>
                                        <div class="modal-footer">
                                          <button type="submit" class="btn btn-primary">Aktifkan</button>
                                          <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
                                        </div>
                                  </div>
                                          </form>
                                </div>
                        </div>
        


then add another

        
                    <script>
                          $('#aktifMagang').on('show.bs.modal', function(event) {
                                var button = $(event.relatedTarget) 
                                var recipient = button.data('siswaid') 
                                var modal = $(this)
                                modal.find('.namasiswa').text(namasiswa)
                                modal.find('.modal-body input').val(recipient)
                          })
                        </script>

                


but The page has expired due to inactivity. Please refresh and try again



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire