May 6, 2021
0
Level 2
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();
Please or to participate in this conversation.