Alexander Cogneau
Alexander Cogneau

Reputation: 1274

JQuery slider change wait half a second before executing

I'm using a JQuery slider for altering some get values of an ajax request. Whenever the the slider changes, it sends a new request with the new values. However: the slider updates it changes too fast. So when I slide it and then drop it somewhere, it sends multiple request at intervals of values I crossed during the sliding. So for example, if I move the slider from 5 to 10, it sends out a request for 6, 7, 9 and finally 10. And it then takes 4-5 seconds to finally update the content to 10.

Is there a way that I can set if, for example, the slider has been on that value for half a second, only then it will make the request? Or do you guys have other solutions?

Thanks in advance!

EDIT: this is the code I'm using:

$("#slider-range").slider({
range: true,
min: 0,
max: 5000,
values: [ 0, 1250 ],
slide: function( event, ui ) {
    refresh();
    }});

And refresh() sends the request and updates the DOM

Upvotes: 2

Views: 366

Answers (1)

jerone
jerone

Reputation: 16881

Without showing us some code, you probably have an event bound on the change event, there is however a Stop event available.

Upvotes: 1

Related Questions