1

okay so i have a ajax script calling a RESTful url, and this is what it's returning to me, some json like so

{
"name": "camera-livingroom",
"address": 0,
"addressStr": "unknown",
"classID": 0,
"devProtocol": 999,
"displayInUI": true,
"displayLongState": "disconnected",
"displayRawState": "disconnected",
"folderID": 476125486,
"hasStateToDisplay": true,
"id": 1241016235,
"lastChanged": 479347270,
"lastChangedDateStr": "2015-03-11",
"lastChangedRFC3339": "2015-03-10T22:01:10Z",
"lastChangedRFC822": "Tue, 10 Mar 2015 22:01:10 GMT",
"lastChangedTimeStr": "12:01:10 AM",
"type": "Camera",
"typeFlags": 0,
"typeSupportsDim": false,
"typeSupportsEnergyMeter": false,
"typeSupportsHVAC": false,
"typeSupportsIO": false,
"typeSupportsOnOff": false,
"typeSupportsSensorValue": false,
"typeSupportsSpeedControl": false,
"typeSupportsSprinkler": false,
"versByte": 0,
"restParent": "devices"
}

This JSON i have no control over, and can't change because it's coming from a api on a program.

I'm calling the JSON with

        <script type="text/javascript">

        function load(Test) {


            $.ajax({
                type: 'GET',
                // TO DO
                url:  'http://SERVERIP:8176/devices/camera-livingroom.json',
                dataType: 'jsonp',
                crossDomain: true,
                success: function(data) {
                    alert(data);
                }
            });

        }

    </script>

    <a class="editLink" onclick="load('Test');">test af link</a>

But this is just returning "SyntaxError: Unexpected token ':'. Parse error."

So what have i done wrong, and what do i do to fix it.

bymem
  • 79
  • 1
  • 8

1 Answers1

0

Your code is working just fine for me, so I did try using $.getJSON, same working result :

$.getJSON( "https://raw.githubusercontent.com/mozilla/contribute.json/master/schema.json?callback=?", function( data ){
  console.log( data );
});
JC Sama
  • 2,214
  • 1
  • 13
  • 13