如何使用JQuery或JavaScript和Fill DropDownList检索sharepoint 2013列表数据?

我正在尝试使用JavaScript检索列表数据。 但出了点问题。 我正在尝试调试代码,但我无法理解那件事。
以下是JavaScript代码:

ExecuteOrDelayUntilScriptLoaded(PopulateDepartments, "sp.js"); var _ctx = null; var _web = null; var _allItems = null; function PopulateDepartments() { debugger; _ctx = SP.ClientContext.get_current(); _web = _ctx.get_web(); var list = _web.get_lists().getByTitle("ServiceType"); var query = new SP.CamlQuery(); query.set_viewXml(""); _allItems = list.getItems(query); _ctx.load(_allItems, 'Include(Title,ID)'); debugger; _ctx.executeQueryAsync(Function.createDelegate(this, this.PopulateDepartmentSuccess), Function.createDelegate(this, this.PopulateDepartmentFaild)); } function PopulateDepartmentSuccess() { var ddlEntry = this.document.getElementById("ddl1"); ddlEntry.options.length = 0; var listEnumerator = _allItems.getEnumerator(); while (listEnumerator.moveNext()) { var currentItem = listEnumerator.get_current(); ddlEntry.options[ddlEntry.options.length] = new Option(currentItem.get_item("Title"), currentItem.get_item("ID")); } } function PopulateDepartmentFaild() { alert("Something went Wrong....!!"); } 

每当我运行此代码时,它会向我显示警报框。
请帮忙..

有时候这没有采用正确的引用。检查它是否可以删除此引用.so而不是这个_ctx.executeQueryAsync(Function.createDelegate(this,this.PopulateDepartmentSuccess),Function.createDelegate(this,this.PopulateDepartmentFaild) ));

尝试使用这样的东西

_ctx.executeQueryAsync(PopulateDepartmentSuccess,PopulateDepartmentFaild);

我想。如果你的创建Sharepoint应用程序,有必要在AppManifest.xml中授予web权限。