0

I have requirement to work on COM Javascript in SharePoint 2013. I have created one ".aspx" page and included script files to access SharePoint site & list using Javascript. However, I am not able to get any results in clientContext. Please review the code below.

<script type="text/javascript" src="/_Layouts/15/Scripts/jquery-1.7.1.min.js">
</script>
<script type="text/javascript" src="/_Layouts/15/Scripts/SP.js"></script>
<script type="text/javascript" src="/_Layouts/15/Scripts/SP.Runtime.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        var siteUrl = "http://mysiteurl/";
        retrieveListItems(siteUrl);
    });
    function retrieveListItems(siteUrl) {
        alert('SiteUrl :' +'\n'+ siteUrl);
        var clientContext = new SP.ClientContext(siteUrl);
        alert('clientContext :' +'\n'+ clientContext)  
    }
</script>
Ryan Erickson
  • 731
  • 1
  • 15
  • 23
  • Did you know there is http://sharepoint.stackexchange.com/ ? It can be a good place for more detailed SharePoint questions. – glenatron Mar 13 '13 at 10:36

1 Answers1

1

You can try SP.ClientContext.get_current() as you only need to pass the url to get a specific site.

Reference: http://msdn.microsoft.com/en-us/library/jj245759.aspx

Ryan Erickson
  • 731
  • 1
  • 15
  • 23