Javascript works in editor, fails in preview?

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
I am testing some Javascript to pull National Weather Service alerts from and show it on the presentation window. It's very simple code, and it works in the layout editor:

However, when I save the presentation and then open the preview window, the code breaks and fails to work. If I press F12 in Google Chrome, it shows an error: "Uncaught SyntaxError: Unexpected end of input"  (program:1)

Is there some sort of bug in the Rise Vision preview window doing this? I am not an expert at Javascript, and so this code is hacked together, but the code works in the editor so I have no idea.

Here is the code, though note if you want to test this code yourself, you need to obtain a free developer "API key" to access their data. I have removed my API key from this example:
<script src=""></script>
jQuery(document).ready(function($) {
		url : "",
		dataType : "jsonp",
		success : function(parsed_json) {
			//	document.write('got here<br>');
			//ensure api gave good data
			if (parsed_json['response']['error']) {
				document.write('<b>API ERROR: </b>'+ parsed_json['response']['error']['description']);
			} else {
			//	document.write('no error detected.<p>');
			//check if there are weather alerts
			if (parsed_json['alerts']['0']) {
				var i=0;
				parsed_json['alerts'].forEach(function() {
					document.write('<font color="'
						+ parsed_json['alerts'][i]['level_meteoalarm_name']
						+ '"><b>ALERT: '
						+ parsed_json['alerts'][i]['message']
						+ '</b></font>');

ATTRIBUTION: Portions of this code were pulled from here and customized:
Photo of Dale Mahalko

Dale Mahalko

  • 170 Points 100 badge 2x thumb

Posted 3 years ago

  • 1
Photo of HSuarez


  • 11,896 Points 10k badge 2x thumb
Hi Dale,

Interesting project - looking at it is using DHT22 data.  I've done a few projects with this sensor ( temperature/humidity sensor ) before (

It's good to have more than one pair of eyes to look at your work...Uncaught SyntaxError: Unexpected end of input"  (program:1) to me indicates that there is an error with your syntax.

I ran the code through this web app ( - it helps with making sense with the code ). I think there is a missing closing the function (ie } ) at the end, see attached screenshot.

I'm not sure if that works, if not, I hope that other people in the community can have a look at your work and the syntax (if not there are other places like Stack Overflow).