jeudi 31 janvier 2019

Laravel ajax request in every row

@section('script')
    @foreach ($unit as $user)
        <script>
                $(document).ready(function(){
                    $('#case_number').keyup(function(){
                        var query = $(this).val();
                        if (query != ''){
                            var _token = $('input[name="_token"]').val();
                            $.ajax({
                                url:"",
                                method:"POST",
                                data:{query:query, _token:_token},
                                success:function(data){
                                    $('#case_number_list').fadeIn();
                                    $('#case_number_list').html(data);
                                }
                            })
                        }
                    });
                });
                $(document).on('click', 'li', function(){
                    $('#case_number').val($(this).text());
                    let y = $(this).val();
                    $('#case_number_hidden').attr('value', y);
                    $('#case_number_list').fadeOut();
                });
        </script>
    @endforeach
@endsection


How to make this loop in every row? Because if I leave it without the foreach it will only work on the first row of the table.

PS: foreach don't work



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2MFZipu
via IFTTT

Aucun commentaire:

Enregistrer un commentaire