webapi/src/components/sp/api/sp.web.js
function (url, site, ctx, loadFunc) {
		return $.Deferred(function (dfd) {

			ctx = ctx || SP.ClientContext.get_current();
			site = site || ctx.get_site();
			var web = (url) ? (typeof url == "string") ? site.openWeb(url) : url : ctx.get_web();
			var res = loadFunc && loadFunc(web) || ctx.load(web);

			ctx.executeQueryAsync(
				function (sender, args) {
					dfd.resolve(web, res, sender, args);
				},
				function onError(sender, args) {
					dfd.reject({ sender: sender, args: args });
					//dfd.reject('Request failed ' + args.get_message() + '\n' + args.get_stackTrace());
				});
		}).promise();
	}
function (url, site, ctx, loadFunc) {
		return $.Deferred(function (dfd) {

			ctx = ctx || SP.ClientContext.get_current();
			site = site || ctx.get_site();
			var web = (url) ? (typeof url == "string") ? site.openWeb(url) : url : ctx.get_web();
			var res = loadFunc && loadFunc(web) || ctx.load(web);

			ctx.executeQueryAsync(
				function (sender, args) {
					dfd.resolve(web, res, sender, args);
				},
				function onError(sender, args) {
					dfd.reject({ sender: sender, args: args });
					//dfd.reject('Request failed ' + args.get_message() + '\n' + args.get_stackTrace());
				});
		}).promise();
	}
function ( url , site , ctx , loadFunc ) { return $ . Deferred ( function ( dfd ) { ctx = ctx || SP . ClientContext . get_current ( ) ; site = site || ctx . get_site ( ) ; var web = ( url ) ? ( typeof url == "string" ) ? site . openWeb ( url ) : url : ctx . get_web ( ) ; var res = loadFunc && loadFunc ( web ) || ctx . load ( web ) ; ctx . executeQueryAsync ( function ( sender , args ) { dfd . resolve ( web , res , sender , args ) ; } , function onError ( sender , args ) { dfd . reject ( { sender : sender , args : args } ) ; //dfd.reject('Request failed ' + args.get_message() + '\n' + args.get_stackTrace()); } ) ; } ) . promise ( ) ; }
Load an existing site
fails if site doesn't exist
@param {string} url - site relative url of web
@param {spsite} site- site reference, if null will load from current context
@param {ClientContext} ctx - SharePoint client context, if null the current context will be used
@param {function} loadFunc - function run before the web is loaded (web will be passed as argument)
Load an existing site fails if site doesn t exist