Getting Started with ECMAScript Client Object Model in Sharepoint 2013
The emergence of dynamic webpages has also encouraged developers to develop efficient web applications with lesser post backs and delays. To interact with efficiency with SharePoint, Microsoft has also introduced a client object model which is very similar to the server object model. Before discussing the objects and methods of the client object model, lets first try to understand the basics of the JavaScript client object model (JSOM) of the SharePoint.
The client object model(JSOM) provides 3 major javascript files which contains all the necessary methods to make an operation on Sharepoint. These javascript files are as follows;
- SP.js
- SP.Core.js
- SP.Runtime.js
The above 3 javascript files resides in {Sharepointroot}\Template\Layouts folder. An WCF webservice named as 'Client.svn' is used by these files to interact with the Sharepoint. This webservice should not be used directly but rather use js files provided by the Microsoft for interaction.
When an HttpRequest is made from the client then a call is made to /_vti_bin/client.svn/Processrequest. The request is a well form Xml but after the processing, the response is in the form of JSON. The response also downloads the required files in the browser. The question here raises is how to download only the files which are being needed? The answer lies in the Script on Demand framework that is being provided. The developer can reference the javascript files which are need by setting the property OnDemand="true" as follows;
Enable Intellisense in JSOM
To enable intellisense on client side, write the following lines of code in the visual webpart;
<% #if SOME_UNDEFINED_CONSTANT %> <% #endif %>








