Defining alternate transports

We've seen that jQuery uses XMLHttpRequest, ActiveX, or <script> tags as appropriate to handle Ajax transactions. If we wish, we can further extend this arsenal with new transports.

A transport is an object that handles the actual transmission of Ajax data. New transports are defined as factory functions that return an object with the .send() and .abort() methods. The .send() method is responsible for issuing the request, handling the response, and sending the data back through a callback function. The .abort() method should stop the request immediately.

A custom transport can, for example, use <img> elements to fetch external data. This allows image loading to be handled in the same way as other Ajax requests, ...

Get Learning jQuery 3 - Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.