0

The task is to create a web-page, which will show the data (temperature, humidity and date) from the Jasonlist of a local web-server on Raspberry Pi. So, I used a command $.getJSON for it and everything works fine, I see the necessary data, but only in Dreamweaver:( When I try to check it in Browser, the JavaScript is blocked (in Chrome, FireFox etc.). Only I can see it in Internet Explorer, because it allow me to unblock "running Javascript" manually. I tried several things (AJAX, sync, async), but the problem that I'm new in JS and I can't find out a simple thing to solve it. The code is following:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HomeMatic Measurements</title>
</head>

<script type="text/javascript" src="http://www.tutorialspoint.com/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" language="javascript">

$.getJSON('http://192.168.1.7:8083/fhem?cmd=jsonlist&XHR=1', function(a) {$.each(a.Results, function(i, b) {$.each(b.devices, function(i, c) {$.each(c.READINGS, function(i, d) {

if(d.humidity    == undefined){} else {$('#data').append('<p> Humidity: '    + d.humidity )}          
if(d.temperature == undefined){} else {$('#data').append('<p> Temperature: ' + d.temperature + '<p> Measured: ' + d.measured )}})})})})
</script>

<body>
<h1>HomeMatic Measurements:</h1>
<div id="data"></div>

</body>
</html>

Looking forward for your feedback. Thank you in advance. Best Regards, Michael.

  • 1
    are you running on localhost? or just opening file? – charlietfl Nov 28 '13 at 18:39
  • Are you also accessing this page from `http://192.168.1.7:8083/`? Cross-origin Ajax [isn't allowed by default](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript). – Jonathan Lonowski Nov 28 '13 at 18:43
  • If this document is served up with an XML file type, escape all the `<` and `&` marks inside the script element, or put the whole script in a CDATA block. In that case, this question would not be a duplicate. – Mr Lister Nov 29 '13 at 11:36

0 Answers0