Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

j_watson's avatar

Lodash _.throttle not working

I'm trying to use Lodash throttle to control how many times my AJAX will run, however, it doesn't seem to work. I don't know if my syntax is wrong or something. I'm grateful for any suggestion.

here is my AJAX

function ajaxThrot(){

                $.ajax({
                    url:"{{ route('id.scanner') }}",
                    type:'POST',
                    datatype: 'json',
                    data:{idNumber:idNumber,
                        _token: '{{csrf_token()}}'
                            },
                            
                    success:function(res){                  
                        alert(res);
                    }      
                });

                }

                function testThrottle(){
                _.throttle(ajaxThrot(), 5000);
            }

            testThrottle();
0 likes
0 replies

Please or to participate in this conversation.