Skip to Content
Learning jQuery - Fourth Edition
book

Learning jQuery - Fourth Edition

by Jonathan Chaffer, Karl Swedberg
June 2013
Beginner content levelBeginner
444 pages
9h 45m
English
Packt Publishing
Content preview from Learning jQuery - Fourth Edition

Throttling Ajax requests

An increasingly common feature of searches is to display a dynamic list of results as the user is typing. We can emulate this "live search" feature for our jQuery API search by binding a handler to the keyup event:

$('#title').on('keyup', function(event) {
  $ajaxForm.triggerHandler('submit');
});

Listing 13.10

Here, we simply trigger the form's submit handler whenever the user types something in the Search field. This could have the effect of sending many requests across the network in rapid succession, depending on the speed at which the user types. This behavior could bog down JavaScript's performance; it could clog the network connection, and the server might not be able to handle that kind of demand.

We're already limiting ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning jQuery 3 - Fifth Edition

Learning jQuery 3 - Fifth Edition

Adam Boduch, Jonathan Chaffer, Karl Swedberg
jQuery Cookbook

jQuery Cookbook

Cody Lindley

Publisher Resources

ISBN: 9781782163145Other