0

I am new to javascript and am trying to process a simple JSON response from an API. But when i run the following code i get nothing.

<!DOCTYPE html>
<html>
<head>
<script     src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
<script>
$(document).ready(function(){
        $.getJSON('http://76.233.189.148:5000/index.json', function(result){
            document.write(result.datasets);
        });
});
</script>
</head>
<body>
</body>
</html>

I know the API is working since from:

http://76.233.189.148:5000/index.json

it returns:

{
  "datasets": [
    {
      "id": "20150803-183949-44df", 
      "name": "Train0010", 
      "status": "Done"
    }
 ], 
  "models": [
    {
      "id": "20150803-184058-97ff", 
      "name": "train0010_alex", 
     "status": "Done"
    }
  ]
 }

What am i doing wrong here?

user2284821
  • 433
  • 6
  • 16
  • 4
    If you open the console, you should ses something like `No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.` As it probably not on the same sites. – fuyushimoya Aug 04 '15 at 07:43
  • it seems you need CORS here – venkat7668 Aug 04 '15 at 07:49
  • I just enabled CORS in my chrome browser but still get no response when i run the page from there. – user2284821 Aug 04 '15 at 08:15
  • Read through this: http://stackoverflow.com/questions/19456146/ajax-call-and-clean-json-but-syntax-error-missing-before-statement – jvv Aug 04 '15 at 08:17

0 Answers0