So, I have (in fact we all do) this cool WCF Odata service by Telerik Kendo UI, for example: (updated with working link) http://demos.telerik.com/kendo-ui/Service/Northwind.svc. Which is very handful for testing purposes.
I would like to invoke it from javascript and show the result as an alert. So, my code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function button(src1) {
$.getJSON('http://demos.kendoui.com/service/Northwind.svc/Tasks(4)/Start?$format=json',
function(json) {
alert(json.d.Start);
});
}
</script>
</head>
<body>
<form id="form1">
<div><input type="button" onclick="javascript:button();" value="Call WCF Service" /></div>
</form>
</body>
</html>
But still in Google Chrome console I get this "Origin null is not allowed by Access-Control-Allow-Origin". Why so?
UPD: The peculiar thing is, I've spotted this code here on stackoverflow somewhere, but with this call instead of mine:
$.getJSON('http://www.panoramio.com/wapi/data/get_photos?v=1&key=dummykey&tag=test&offset=0&length=20&callback=?&minx=-30&miny=0&maxx=0&maxy=150',
function(json) {
alert(json.photos[1].photoUrl);
});
And this one works. Why Kendo's doesn't?