REST实现页面访问量查询修改
//总浏览量 function SeachTotalCount(){ var par = encodeURIComponent("统计"); $.ajax({ url: "/_api/web/lists/getbytitle('"+ par +"')/items?$select=Title,ID,Count&$filter=ID eq 4", type: "GET", headers: { "accept": "application/json;odata=verbose" }, success: function(data){ var articleresults = data.d.results; UpdateTotalCount(articleresults[0].Count+1) }, error:onError }); } //修改统计数 function UpdateTotalCount(count){ var par = encodeURIComponent("统计"); var url="/_api/Web/Lists/GetByTitle('"+par+"')/Items(4)"; var data = { __metadata: { 'type': 'SP.Data.StatisticsListItem' }, Count: count }; $.ajax({ url: url, type: "POST", data: JSON.stringify(data), headers: { "X-HTTP-Method":"MERGE", "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), "IF-MATCH": "*" }, error: onError }); }