This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tries to execute the uri:scheme | |
function uriSchemeWithHyperlinkFallback(uri, href) { | |
// set up a timer and start it | |
var start = new Date().getTime(), | |
end, | |
elapsed; | |
// attempt to redirect to the uri:scheme | |
// the lovely thing about javascript is that it's single threadded. | |
// if this WORKS, it'll stutter for a split second, causing the timer to be off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery Headers support for $.ajax | |
$.ajax({ | |
beforeSend: function(xhrObj){ | |
xhrObj.setRequestHeader("Content-Type","application/json"); | |
xhrObj.setRequestHeader("Accept","application/json"); | |
} | |
type: "POST", | |
url: "/article", | |
processData: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function addXhrProgressEvent($) { | |
var originalXhr = $.ajaxSettings.xhr; | |
$.ajaxSetup({ | |
progress: function() { console.log("standard progress callback"); }, | |
xhr: function() { | |
var req = originalXhr(), that = this; | |
if (req) { | |
if (typeof req.addEventListener == "function") { | |
req.addEventListener("progress", function(evt) { | |
that.progress(evt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* converted stringify() to jQuery plugin. | |
* serializes a simple object to a JSON formatted string. | |
* Note: stringify() is different from jQuery.serialize() which URLEncodes form elements | |
* UPDATES: | |
* Added a fix to skip over Object.prototype members added by the prototype.js library | |
* USAGE: | |
* jQuery.ajax({ |