I need to pull/post data ( list items ) from/to SharePoint online to/from another environment like HTML, PHP that hosted externally or in WordPress to share it with the public.
I tried this JS code but unfortunately it is not working ... could you please tell me where is the problem :
$(function (){
function retrieveListItem()
})
function retrieveListItem(){
var siteURL =new SP.ClientContext('https://******.sharepoint.com');
var fullUrl = siteURL+"/_api/web/lists/GetByTitle('Cities')/items";
$.ajax({
url: fullUrl,
type:"GET",
headers:{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
},
seccess: onQuerySucceeded,
error: onQueryFaild
});
}
function onQuerySucceeded(data){
var listItemInfo='';
$.each(data.d.results, function (key, value){
listItemInfo +='<strong>ID:' +value.Title+'<br />'
});
$("#divListItems").html(listItemInfo);
}
function onQueryFaild(sender, args){
alert('Error!');
}
HTML code :
<div id="divListItems">
</div>