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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.