I am creating a subiste by using the below javascript code.I want to check if a subsite exists or not before creating it. I ma creating a susiste on button click function like below
<
div>
<div>
<input type="test" id="text" /><input type="button" id="button" value="Create Site " />
</div>
$('#button').click(function() {
var mytest= $("#text").val();
alert(mytest);
createWebsite(mytest);
});
Can any one help me on this .
Creating a subsiste function
function createWebsite(SiteName) {
var clientContext = SP.ClientContext.get_current();;
var collWeb = clientContext.get_web().get_webs();
var webCreationInfo = new SP.WebCreationInformation();
webCreationInfo.set_title(SiteName);
webCreationInfo.set_description('Description of new Web site...');
webCreationInfo.set_language(1033);
webCreationInfo.set_url(SiteName);
webCreationInfo.set_useSamePermissionsAsParentSite(true);
webCreationInfo.set_webTemplate(siteTemplate);
var oNewWebsite = collWeb.add(webCreationInfo);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert("Created Web site.");
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}