I created a test custom .aspx page in sharepoint 2010 and I want to get client object model (javascript) working on it, without loading the master page.

However when I load the page, I get this error:

[10:47:22.513] ReferenceError: FV4UI is not defined @ http://XXXX/_layouts/1033/core.js:2
[10:47:24.882] ReferenceError: IEnumerator is not defined @ http://XXXX_layouts/sp.runtime.js:2
[10:47:28.247] TypeError: SP.ScriptUtility is undefined @ http://XXXX/_layouts/sp.js:2

This is what I have so far:

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" %>

<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


    <%-- <SharePoint:ScriptLink ID="ScriptLink1" language="javascript" name="core.js" runat="server" /> --%>
    <%-- <SharePoint:ScriptLink language="javascript" name="SP.js" defer="true" runat="server" Localizable="false"/> --%>



    <form id="form1" runat="server">


<script type="text/javascript" src="./includes/js/jquery/jquery-2.0.2.min.js"></script> 
<script type="text/javascript" src="/_layouts/1033/core.js"></script>
<script type="text/javascript" src="/_layouts/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/1033/init.js"></script>
<script type="text/javascript" src="/_layouts/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/sp.js"></script>
<!-- <script type="text/javascript" src="/_layouts/sp.taxonomy.js"></script> -->

    <script type="text/javascript">
        // occurs when the document is ready
        $(document).ready(function() {
            // wait for the sharepoint javascript libraries to load, then call the function 'Initialize'
            ExecuteOrDelayUntilScriptLoaded(runCode, "sp.js");


        var listItems;                   // The list of retrieved items.
        var query;                       // For paging, reuse the same query object.
        var targetList;                  // The list from which to retrieve items.
        var clientContext;

        function runCode() {
            clientContext = new SP.ClientContext();
            web = clientContext.get_web();  
            targetList = web.get_lists().getByTitle("Documents");
            query = new SP.CamlQuery();

            var CAML = "<View><Query><OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy></Query></View>";
            var CS = "Include(Title,FileRef)";

            //Specifying the RowLimit will determine how many items will be fetched in one call to the server.
            listItems = targetList.getItems(query);
            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));

        function onQuerySucceeded(sender, args) {
            var message = "Titles, two at a time:\n";
            var listEnumerator = listItems.getEnumerator();
            while (listEnumerator.moveNext()) {
                message += "\nTitle=" + listEnumerator.get_current().get_item("Title")

            //Gets the id of the last element from the returned collection along with the query.
            var position = listItems.get_listItemCollectionPosition();
            //Position will be null if all the items in the collection are fetched and there are no more items to be fetched.
            if (position != null) {
                //If more items are to be fetched, make a second call to the server and fetch the next group of items.
                listItems = targetList.getItems(query);
                //Call the same function recursively until all the items in the current criteria are fetched.
                clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));

        function onQueryFailed(sender, args) {
            alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());



1 Answer 1


I was able to get the sample running that you referenced in http://allthatjs.com/2012/04/03/using-sharepoint-csom-in-html5-apps - with a few changes.

Note the form digest, and all five javascript files must be referenced in this order. Also note the site URL is explicitly given. Using get_current will not work. And the URL must be in the current site collection.

Here's my version, which incorporates one of the simple code examples given in the link.

<!DOCTYPE html>
<%@ Page language="C#" %>
<%@ Register Tagprefix="SharePoint" 
     Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
    <!-- the following 5 js files are required to use CSOM -->
    <script type="text/javascript" src="/_layouts/1033/init.js"></script>
    <script  type="text/javascript" src="/_layouts/MicrosoftAjax.js"></script>
    <script  type="text/javascript" src="/_layouts/sp.core.js"></script>
    <script  type="text/javascript" src="/_layouts/sp.runtime.js"></script>
    <script  type="text/javascript" src="/_layouts/sp.js"></script>

   <script type="text/javascript">
 // define a ClientContext for the specified SP site
var ctx = new SP.ClientContext("/sites/theSite"); 
//passing url explicitly to client context. and the url must be in the current site collection
// attach a onRequestFailed function to the client context.
ctx.add_requestFailed(function (sender, args) {
    alert('Request failed: ' + args.get_message());

function example () {
    var web = ctx.get_web();

    ctx.executeQueryAsync(function () {
        alert("Title: " + web.get_title());
        alert("Description: " + web.get_description());

window.onload = example;


    <SharePoint:FormDigest ID="FormDigest1" runat="server"></SharePoint:FormDigest>
  • Your a life saver.
    – omega
    Commented Jun 4, 2013 at 22:57
  • Evidently this doesn't work in SharePoint Online (403 forbidden). If I find a solution I'll come back and update my answer. Commented Aug 30, 2013 at 17:29
  • Get a 404 error for the Microsoft AJAX
    – BeerusDev
    Commented Jun 22, 2022 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.