[英]Exposing Sharepoint 2013 REST API Get using JavaScript
What I'm trying to do (long term) is process list data and have it pop up on a separate page for management consumption. 我想要做的(长期)是流程列表数据,并在一个单独的页面上弹出以供管理使用。 I've successfully used REST APIs in workflows and now I'm trying my hand at using them in Javascript (something I'm a new to).
我已经在工作流中成功使用了REST API,现在我正在尝试在Javascript中使用它们(这是我的新手)。 My code seems to have success in getting the data.
我的代码似乎已成功获取数据。 My trouble is how to get at the data so I can process it and then display onto a page in Sharepoint.
我的麻烦是如何获取数据,以便我可以对其进行处理,然后显示在Sharepoint中的页面上。 A simple example would be great to get me started.
一个简单的例子将使我入门。
My code I've attached is in a CEWP. 我所附的代码在CEWP中。
Thanks in advance. 提前致谢。
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl +
"/_api/web/lists/getbytitle('MyList')/items",
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data) {
console.log("Success in getting the data");
},
error: function(data) {
console.log("Error in getting List");
}
});
</script>
You can loop through the data in success function and add to dom 您可以遍历成功功能中的数据并添加到dom
success: function(data){
data = data.d.results;
$.each(data, function(index, value) {
console.log(value)
$(body).append(value.title)
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.