Creating SPWeb’s using Client Object Model (CSOM)

This is a quick example of how to use the JavaScript client object model to create a new SPWeb. As a bonus, this also covers adding it to the root of the site collection. Now, remember in SP2013 if you are doing this from an app you will need to request rights to either the hosting SPWeb of your app or the hosting SPSite. Otherwise you’ll just get access denied errors.