_spPageContextInfo javascript or jquery variable in SharePoint 2013

_spPageContextInfo variable provides few properties which will be useful in JavaScript and client object model code. We can use _spPageContextInfo variable in SharePoint 2013 or SharePoint online to retrieve various properties. _spPageContextInfo is a JavaScript/jquery context variable, which will rendered for each SharePoint page. _spPageContextInfo holds few proprieties which will be useful in JavaScript/jquery and client object model code. If you want to know the properties of _spPageContextInfo, go to view page source and find text with “_spPageContextInfo”.

Read some SharePoint tutorials on:

When It will be useful:
– When we are making any ajax calls, we might need the server URL dynamically. In this case we can use _spPageContextInfo.siteAbsoluteUrl property.

– If you want to know the current SharePoint List GUID, use _spPageContextInfo.pageListId.

– Even it has more properties also(which are self explanatory). We can use them according to the requirements.

Sample Code:

beforeSend: function (request) {
request.setRequestHeader(“Accept”, “application/json;odata=verbose;charset=utf-8″);
url: _spPageContextInfo.siteAbsoluteUrl +”/_api/search/query?querytext='” + request.term + “*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31’&rowlimit=’20’&selectproperties=’FirstName,AccountName,PictureURL,SipAddress,PreferredName,Country,City'”,
dataType: “json”,
success: function (data) {
response($.map(data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results, function (item) {
return {
fields: getFields(item.Cells.results)
error: function (data) {
alert(‘search error’);

_spPageContextInfo Object Properties found for SharePoint 2013 application:
– alertsEnabled: false
– allowSilverlightPrompt :”True”
– clientServerTimeDelta :-8980
– crossDomainPhotosEnabled: false
– currentCultureName: “en-US”
– currentLanguage: 1033
– currentUICultureName: “en-US”
– layoutsUrl: “_layouts/15”
– pageListId: “{df5e2d45-ad0b-4608-a813-ded6a97511db}”
– pagePersonalizationScope: 1
– serverRequestPath: “/sites/ SharepointSite /Lists/ custom/ custom.aspx”
– siteAbsoluteUrl: “http://svr:2525/sites/ SharepointSite ”
– siteClientTag: “0$$15.0.4433.1506”
– siteServerRelativeUrl; “/sites/ SharepointSite ”
– systemUserKey: “i:0).w|s-1-5-21-2086049…90378103-3194450012-500”
– tenantAppVersion: “0”
– userId: 1
– webAbsoluteUrl: “http:// svr:2525/sites /sites/SharepointSite”
– webLanguage: 1033
– webLogoUrl:”_layouts/15/images/siteicon.png”
– webPermMasks: Object { High=2147483647, Low=4294967295}
– webServerRelativeUrl: “/sites/ SharepointSite ”
– webTemplate: “1”
– webTitle : ” SharepointSite ”

Hope this will be useful.

You May Also like the Following SharePoint Online Tutorials:

About Sagar Pardeshi

I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.

View all posts by Sagar Pardeshi →