Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(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
You can’t perform that action at this time.