respondTo jQuery plugin

Posted on 12 Jan 2010. in links javascript

respondTo is a jQuery plugin that allows you to supply handlers for different AJAX response content types. In practice, it looks something like this:

    $.respondTo({
        url: '/people/37',
        html: function(html, status) {
            // handle HTML response
        },
        json: function(json, status) {
            // handle JSON response
        }
    });

The naming bothers me (it looks like it’s adding a route listener instead of making an AJAX request), but it looks pretty useful. The library can also override the existing jQuery AJAX methods, if desired.