Last active
August 29, 2015 14:04
-
-
Save phillipharding/075f176cb4659c8de342 to your computer and use it in GitHub Desktop.
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($) { | |
"use strict"; | |
function checkSPWebResource(url, async) { | |
var | |
endpoint = url.match(/^http[s]?:\/\//i) || url.match("^"+_spPageContextInfo.webServerRelativeUrl) | |
? url | |
: _spPageContextInfo.webServerRelativeUrl.replace(/\/$/g,'') | |
+ '/' + url.replace(/^\//g,''), | |
p = $.Deferred(); | |
$.ajax({ type: 'HEAD', url: endpoint, async: (typeof async !== "undefined" ? async : true) }) | |
.done(function(response, textStatus, xhr) { | |
p.resolve({ status: true, url: endpoint }); | |
}) | |
.fail(function(xhr, textStatus, err) { | |
p.reject({ status: false, url: endpoint }); | |
}); | |
return p.promise(); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment