I am trying to get some data from a REST Service Url in a html file. This works fine when i am using the code direct in my browser. But when i embedded it into my SharePoint Site it wont work.
On my SharePoint Site i have disable MDS (Minimal Download Strategy).
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var getdata = function() {
$.ajax({
url: "http://resturl:8080/api/v2/table/_table/v_name?api_key=2e02708088e54b560b33dbcb1e13b7e1488907534262b319d86b58c480fea54c",
type: "GET",
async: false,
headers: {
"accept": "application/json;odata=verbose"
},
}).success(function (data) {
alert("got data");
});
}
var chartdata = getdata();
</script>
</head>
<body>
<h1>Some Text</h1>
</body>
For receiving this data i have to add the api_key to the url or the request.
The response code will be a json format, here a snippet:
{"resource":[{"id":22611},{"id":22649}],"meta":{"count":2661,"next":1000}}
Can anyone tell me why i am get no data when i using this html file out of sharepoint. The authorization should come with the api_key ?!
I also tried this code (because for json support in internet explorer etc.)
jQuery.support.cors = true;
jQuery.getJSON('http://resturl:8080/api/v2/table/_table/v_name?api_key=2e02708088e54b560b33dbcb1e13b7e1488907534262b319d86b58c480fea54c',
function(data) {
alert("yeah");
}
)
.error(function(jqXHR, textStatus, errorThrown) { alert(errorThrown); });
Thanks for any help.