Skip to content

Instantly share code, notes, and snippets.

View tiptronic's full-sized avatar

Andy Fuchs tiptronic

  • Bad Bevensen, Germany
  • 03:54 (UTC +02:00)
  • X @tiptronic
View GitHub Profile
@tiptronic
tiptronic / xhr.js
Last active December 20, 2015 05:49 — forked from mythz/xhr.js
- enhance compatibility to jquery and add responseJSON if datatype is set to JSON - remove references to window, so it can run in a webworker
//Adds $.xhr and jQuery-like $.ajax methods to the prescribed namespace.
//Inspired from David Flanagans excellent cross-platform utils http://www.davidflanagan.com/javascript5/display.php?n=20-1&f=20/01.js
//Includes underscore.js _.each and _.extend methods
//modified to behave like jQuery's $.ajax(), not complete.
(function($) {
var xhrs = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject("Microsoft.XMLHTTP"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP"); }