1

关于js和sharepoint交互的一个简单问题

我在asp页面中创建了一个js来从sharepoint检索列表项,我是这样写的:

$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(find, "sp.js"); });
 window.onload = function () {
 find();
}
function loadConstants() {     
    var clientContext = new SP.ClientContext.get_current(); ;
    this.web = clientContext.get_web();     
    var lists = web.get_lists();
    var list = lists.getByTitle("Weekend's Notes");
    var camlQuery = new SP.CamlQuery();
    this.items = list.getItems(camlQuery);
    clientContext.load(items);     
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

下面是查找方法

function onQuerySucceeded(sender, args) {
        var listItemInfo = '';
        var listItemEnumerator = collListItem.getEnumerator();
        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();
            //document.getElementById("ctl00_m_g_826af611_885a_4a36_8141_91157fa66535_ctl00_TextArea1").innerHTML = oListItem.get_item('Note');

        }
    }

每次刷新浏览器时,它都会显示Uncaught TypeError: Cannot read property 'get_current' of undefined 有人能帮帮我吗?完全没有这方面的想法...

4

1 回答 1

0

似乎您在创建 ClientContext 之前运行了脚本。看看这是否有帮助:

http://msdn.microsoft.com/en-us/library/jj245759(v=office.15).aspx

于 2012-11-06T20:26:53.360 回答