I’m trying to make a little web app to control pimatic. But i can’t get it to work with jQuery. With php it works fine but I want to use jQuery.
This works fine:
$json = file_get_contents('http://user:pass@192.168.1.50/api/variables/kamers-links-temp.Temperatuur%20kantoor');
$json = json_decode($json,true);
$array = $json['variable'];
echo $array['value'];
this doesn’t, when i use a local json file it works.
$("button").click(function(){
$.getJSON( "http://user:pass@192.168.1.50/api/variables/kamers-links-temp.Temperatuur%20kantoor", function( data ) {
var items = [];
$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
});
});