I am creating the webpart in my app for SharePoint 2013 and office 365. I have tried to accessing the SharePoint list in my webpart using ajax request like this,
$.ajax({
type: "GET",
dataType: 'json',
url: siteURL + "/_vti_bin/ListData.svc/" + listName,
error: function (evt) {
alert("Error");
},
success: function (data) {
// Processing the data.
}
});
It throws cross domain accessing error message. If i add a 'Access-Control-Allow-Origin' headers to access the cross domain then it shows "preflight is invalid redirect error" message. How to get the sharepoint list items in custom webpart.