jQuery.ajaxTransport(dataType, handler) (since 1.5) registers a factory that can return a transport object with send and abort. jQuery uses that object to transmit the request for the given dataType.
Remember
$.ajaxTransport(dataType, function (options, originalOptions, jqXHR) {
if (/* can handle */) {
return {
send: function (headers, completeCallback) { /* transmit */ },
abort: function () { /* cancel */ }
};
}
// return undefined → jQuery tries another transport
});
// Pipeline: ajaxSetup → ajaxPrefilter → transport.send → completeCallback
Click #go → built-in XHR + JSON handling
#out shows the user name
No custom transport registered
How It Works
Built-in. jQuery already transports JSON over XHR.
Shorthand.$.getJSON() sets the right dataType for you.
Simpler. Prefer prefilters for headers/url tweaks.
Rule. Add a transport only when nothing else can transmit the data.
Edge Cases & Pitfalls
Check these before shipping a custom transport.
factory
Always return a fresh object
Never reuse one shared transport across requests — concurrent calls need isolated state.
responses
Match the dataType key
Put the payload under responses[yourDataType] so .done() receives it reliably.
abort
Ignore late callbacks after abort
Clear timers/handlers in abort so a cancelled request cannot call completeCallback later.
scope
Do not replace XHR for normal APIs
JSON/HTML/script already have built-in transports. Prefer prefilters for option tweaks.
Compatibility
Browser Support
jQuery.ajaxTransport() has been part of jQuery since 1.5. It works wherever your loaded jQuery Ajax module runs.
✓ Stable · jQuery 1.5+
jQuery.ajaxTransport()
Supported across modern jQuery 1.x/2.x/3.x builds that include Ajax. Prefer current jQuery 3.x. Note: the single-object completeCallback form is newer (3.8+ / 4.1); positional args work broadly.
100%jQuery Ajax API
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
$.ajaxTransport()Universal
Bottom line: Available wherever jQuery Ajax runs. Keep transports rare — most apps never need a custom one.
Analysis
Performance Notes
Approach
Cost
Best for
Built-in XHR / JSON
Cheap
Normal HTTP APIs
$.ajaxPrefilter()
Cheap
Option tweaks, early abort
Custom transport
More code · careful abort
Non-HTTP / special dataTypes only
Transport registration itself is cheap. Complexity comes from owning send/abort correctly — especially under concurrent requests.
Remember
Key Takeaways
Role: lowest-level hook that actually transmits Ajax data.
Prefer first: prefilters and converters before writing a transport.
One line:$.ajaxTransport() lets you own send/abort for a dataType — powerful, rare, and usually unnecessary.
Frequently Asked Questions
jQuery.ajaxTransport(dataType, handler) registers a factory that jQuery calls when selecting how to transmit a request for that dataType. If the factory can handle the call, it returns an object with send and abort. Otherwise it returns undefined and jQuery tries another transport. This is the lowest-level Ajax extension point.
send(headers, completeCallback) starts transmission and must eventually call completeCallback when finished. abort() cancels an in-flight request — clear timers, detach Image handlers, or ignore late callbacks so completeCallback does not fire after cancel.
On jQuery 3.7 (common in tutorials), use the positional form: completeCallback(status, statusText, responses, headers). status is like 200 or 404; statusText is "success" or "error"; responses maps dataType keys to values (for example { image: imgElement }); headers is an optional response-header string. Newer jQuery versions also accept a single params object.
ajaxPrefilter runs earlier to tweak options (url, headers, cache) or abort. ajaxTransport replaces how bytes are sent and received for matching dataTypes. Prefer prefilters for option changes; use transports only when prefilters and converters are not enough.
As a last resort: custom protocols, Image-based loads, in-memory mocks, or non-HTTP sources. For ordinary JSON, HTML, or script requests, built-in $.ajax() transports already work — do not register a custom transport.
Each request needs its own transport instance with isolated state (timers, Image nodes, sockets). Registering one shared object would let concurrent requests clobber each other. The factory returns a fresh { send, abort } per matching request.