Anyone who had done a jquery Throttle function?
I make a function like this:
- function throttle(fn, delay) {
- var timer = null;
- return function () {
- var context = this, args = arguments;
- clearTimeout(timer);
- timer = setTimeout(function () {
- fn.apply(context, args);
- }, delay);
- };
- }
-
- // so when you do this with jQuery, here is what you should do
- $('input.username').keypress(throttle(function (event) {
- // do the Ajax request
- }, 250));
and i find a problem , if my request to the server have no response, what should i do then ?