jQuery: filtering HTML results in AJAX

Filtering HTML results with jQuery and AJAX is simple, provided that you understand the basic principles behind the AJAX parsing of an HTML document. When you set the dataType parameter to html using the $.ajax() wrapper method, you're actually telling jQuery to return a full DOM structure that you can traverse with normal jQuery DOM methods. This is made possible by jQuery thanks to its internal selector engine that allows you to treat the returned HTML either as a string or as a DOM structure.

JavaScript: method chaining

JavaScript allows us to chain methods by simply making methods return the this keyword, that is, themselves. So you can have method1().method2().methodN() and so on, all members of the same chain. This turns out to be very useful when you want to concatenate some subroutines and, most of all, when you want to keep your code tidy and organized by avoiding functions and methods that make too much. The basic structure is as follows: