关于js和sharepoint的小Q.

时间:2012-11-06 18:27:34

标签: c# javascript jquery asp.net sharepoint

关于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');

        }
    }

每次刷新浏览器时,都会显示未捕获的TypeError:无法读取未定义的属性'get_current' 有人可以帮我一把吗?完全没有任何想法...

1 个答案:

答案 0 :(得分:0)

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

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