Skip to content

Instantly share code, notes, and snippets.

@rmdort
Created November 25, 2014 02:30
Show Gist options
  • Select an option

  • Save rmdort/e31ae31a1eed10def372 to your computer and use it in GitHub Desktop.

Select an option

Save rmdort/e31ae31a1eed10def372 to your computer and use it in GitHub Desktop.
// Create transport if the browser can provide an xhr
if ( xhrSupported ) {
jQuery.ajaxTransport(function( options ) {
// Cross domain only allowed if supported through XMLHttpRequest
if ( !options.crossDomain || support.cors ) {
var callback;
return {
send: function( headers, complete ) {
var i,
xhr = options.xhr(),
id = ++xhrId;
// Open the socket
xhr.open( options.type, options.url, options.async, options.username, options.password );
// Apply custom fields if provided
if ( options.xhrFields ) {
for ( i in options.xhrFields ) {
xhr[ i ] = options.xhrFields[ i ];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment