How to Call SharePoint 2013 API Service to Query The Lists
2024-10-18 18:28:15
How to Call SharePoint 2013 API
In SharePoint 2013, we can query the list by it owner service, then dynamic load the info of the list items to render in client.
Here is the require, dynamic load the info about the list named link and show to the page in datail.
Here is my steps:
1. Create a link list named "Links", and create a column named "Category", the column is use for category the links, and filter the items. the add some items.
2. Edit the page that you want to show the Links list items. and add the webpart named Script Edittor to store the js code. then edit the webpart and add the js code into the webpart.
Here is the code:
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
</script>
$(document).ready(function () {
ExecuteOrDelayUntilScriptLoaded(getLinksInfo, "sp.js");
});
function getLinksInfo() { var requestUri = "http://dev-sp"+ "/_api/Web/Lists/getByTitle('Links')/items";
var ulIcons = $("#test"); $.ajax({
url: requestUri,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function (data) { var items = "";
$.each(data.d.results, function (index) {
switch ($(this).attr("Category")) {
case "Operations":
items += "<li><a href='mailto:" + $(this)[0].URL.Url+ "'>" + $(this)[0].URL.Description + " - Operation" + "</a></li>"
break;
case "Marketing":
items += "<li><a href='" + $(this)[0].URL.Url + "'>" + $(this)[0].URL.Description + " - Markrting" + "</a></li>"
break;
} }); if (items != "") {
ulIcons.html("");
ulIcons.html(items);
}
},
error: function (e) {
alert("Failed to get Escalations Icons!");
}
});
} </script>
3. Clicke "Ok" abdou the script webpart and save the page. It wiil show the result
最新文章
- Redis简单案例(二) 网站最近的访问用户
- 【Win 10应用开发】响应系统回退键的导航事件
- 客户端调用 WCF 的几种方式
- JavaScript—之对象参数的引用传递
- Mysql备份系列(3)--innobackupex备份mysql大数据(全量+增量)操作记录
- JavaWeb---总结(十)JSP标签
- 转:C/C++中,空数组、空类、类中空数组的解析及其作用
- hibernate学习笔记6--Criteria查询方式、完整小练习(开发步骤)
- Excel引用
- [PHP] PHP Excel导出 以及编码问题
- ibatis.net调用oracle存储过返回游标SYS_REFCURSOR结果集
- DataBase First创建数据库
- POJ 2502 Subway-经过预处理的最短路
- python 3 dict函数 神奇的参数规则
- 常用域名记录解释:A记录、MX记录、CNAME记录、TXT记录、AAAA记录、NS记录
- 转载:遇到BITMAP CONVERSION TO ROWIDS 后解决与思考
- Centos7 linux 卸载自带安装的jdk 并yum自动安装jdk1.8
- 检测到包降级: Microsoft.Extensions.Configuration.Abstractions 从 2.1.1 降 2.1.0
- 读懂 PetaLinux:让 Linux 在 Zynq 上轻松起“跑”(转)
- 【ContestHunter】【弱省胡策】【Round7】