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

最新文章

  1. Redis简单案例(二) 网站最近的访问用户
  2. 【Win 10应用开发】响应系统回退键的导航事件
  3. 客户端调用 WCF 的几种方式
  4. JavaScript—之对象参数的引用传递
  5. Mysql备份系列(3)--innobackupex备份mysql大数据(全量+增量)操作记录
  6. JavaWeb---总结(十)JSP标签
  7. 转:C/C++中,空数组、空类、类中空数组的解析及其作用
  8. hibernate学习笔记6--Criteria查询方式、完整小练习(开发步骤)
  9. Excel引用
  10. [PHP] PHP Excel导出 以及编码问题
  11. ibatis.net调用oracle存储过返回游标SYS_REFCURSOR结果集
  12. DataBase First创建数据库
  13. POJ 2502 Subway-经过预处理的最短路
  14. python 3 dict函数 神奇的参数规则
  15. 常用域名记录解释:A记录、MX记录、CNAME记录、TXT记录、AAAA记录、NS记录
  16. 转载:遇到BITMAP CONVERSION TO ROWIDS 后解决与思考
  17. Centos7 linux 卸载自带安装的jdk 并yum自动安装jdk1.8
  18. 检测到包降级: Microsoft.Extensions.Configuration.Abstractions 从 2.1.1 降 2.1.0
  19. 读懂 PetaLinux:让 Linux 在 Zynq 上轻松起“跑”(转)
  20. 【ContestHunter】【弱省胡策】【Round7】

热门文章

  1. Windows:文件服务器,访问进去不能查看到完整的文件
  2. dll 导出函数名的那些事
  3. mysql 不允许连接
  4. C/C++操作MySQL数据库——增、删、改、查
  5. jquery 根据年 月设置报表表头
  6. DIOCP之DEMO学习顺序及达到要求
  7. spilt()的用法
  8. IOS开发者
  9. HTML5和CSS3基础教程(第8版)-读书笔记(3)
  10. MYSQL存储过程:批量更新数据2(产品品牌)