ReferenceError:未定义网站

时间:2016-04-07 20:57:15

标签: jquery

我正在为SharePoint 2013构建一个图像滚动条,我收到此错误指向此行,我不确定为什么。我正在学习html / js,所以我很感激所有的帮助。

这是返回错误的代码中的行

var oList = website.get_lists().getByTitle(bannerListName);     

还有更多,但这是什么阻止它。

(function()
{
/********************* User Defined Variables ***************************************
**** Update the variables below to customize how the banner rotator works ***********/
var bannerListName = "Banner Rotator"; //the name of the list to pull the banner items from
var interval = 7; //time to wait before showing the next picture (in seconds)
var showPages = false; //change to false if you do not want to show the page numbers

//if you know how to write CAML you can update this string
//by default it looks for all items in the list, but you can change that here
var query = '<View><Query><Where><Geq><FieldRef Name=\'ID\'/><Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>';
/***********************************************************************************/

//global variables
var index = 0;
var bannerList = [];

$(document).ready(function() 
{ 
        // make sure the SharePoint script file 'sp.js' is loaded before code runs
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext',start);
                        });

function start()
{
    ctx = SP.ClientContext.get_current();
    this.site = ctx.get_site();
    this.website = ctx.get_web();
    var oList = website.get_lists().getByTitle(bannerListName);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml(query);
    this.collListItem = oList.getItems(camlQuery);
    ctx.load(collListItem);
    this.ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);

}

1 个答案:

答案 0 :(得分:1)

它应该是this.website而不仅仅是website

this.website = ctx.get_web();   //<-- you store it in this.website, not var website
var oList = this.website.get_lists().getByTitle(bannerListName);