<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Alert from inside function]]></title><description><![CDATA[<p dir="auto">I want to display a notification every time the interval runs. I get this error message:</p>
<p dir="auto"><code>Uncaught TypeError: this.sendNotification is not a function at OV.js:40</code></p>
<p dir="auto">I think is thas something to do with where I place it because if I place it outside the interval function it does work. Maybe someone can point me in the right direction.</p>
<pre><code>Module.register("OV",{
   // Default module config.
   defaults: {
   	text: "Openbaar Vervoer!lsdksdkk"
   },
   
   // Override dom generator.
   getDom: function() {
   	var wrapper = document.createElement("div");
   	
   	function updateOV() {
   	this.sendUpdate;
   	var xhttp = new XMLHttpRequest();
   	xhttp.onreadystatechange = function() {
   		if (this.readyState == 4 &amp;&amp; this.status == 200) {
   		var string = "";
   		//console.log(this.responseText);
   		var data = JSON.parse(this.responseText);
   		//console.log(decodeURI(data.dest));
   		string += "&lt;table&gt;";
   		$.each(data, function( index, value ) {
   			string += "&lt;tr&gt;"
   			console.log(value );
   			string += "&lt;td&gt;" + value.service + "&lt;/td&gt;";
   			string += "&lt;td&gt;" + decodeURI(value.dest) + "&lt;/td&gt;";
   			string += "&lt;td&gt;" + value.time + "&lt;/td&gt;";
   			string += "&lt;td&gt;" + value.state + "&lt;/td&gt;";
   			string += "&lt;/tr&gt;";
   		});
   		string += "&lt;/table&gt;";
   		wrapper.innerHTML = string;
   		}
   	  };
   	  xhttp.open("GET", "http://192.168.1.167/esp/bustijden.php");
   	  xhttp.send();
   	}
   	
   	setInterval(function() {
   		updateOV();
   		this.sendNotification("SHOW_ALERT", {title: "OV", message: "Bustijden ge-update.", timer: "1000"});
   	}, 10000);
   	updateOV();
   	
   	return wrapper;
   },
   
   getScripts: function() {
   return [
   	'https://code.jquery.com/jquery-2.2.3.min.js',  // this file will be loaded from the jquery servers.
   ]
   },

});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/topic/2522/alert-from-inside-function</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 23:24:41 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/2522.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 May 2017 12:51:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alert from inside function on Tue, 09 May 2017 11:05:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/luukth" aria-label="Profile: Luukth">@<bdi>Luukth</bdi></a> <a href="https://github.com/MichMich/MagicMirror/tree/master/modules" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/MichMich/MagicMirror/tree/master/modules</a><br />
or you also can checkout some modules</p>
]]></description><link>https://forum.magicmirror.builders/post/21346</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/21346</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Tue, 09 May 2017 11:05:49 GMT</pubDate></item><item><title><![CDATA[Reply to Alert from inside function on Tue, 09 May 2017 09:35:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/strawberry-3.141" aria-label="Profile: strawberry-3.141">@<bdi>strawberry-3.141</bdi></a> said in <a href="/post/21342">Alert from inside function</a>:</p>
<blockquote>
<p dir="auto">I suggest to outsource the data query from the render function</p>
</blockquote>
<p dir="auto">Can you maybe link me to a documentation. I can’t really find a good way to learn how to make al of those functions.</p>
]]></description><link>https://forum.magicmirror.builders/post/21343</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/21343</guid><dc:creator><![CDATA[Luukth]]></dc:creator><pubDate>Tue, 09 May 2017 09:35:12 GMT</pubDate></item><item><title><![CDATA[Reply to Alert from inside function on Tue, 09 May 2017 09:20:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/luukth" aria-label="Profile: Luukth">@<bdi>Luukth</bdi></a> I suggest to outsource the data query from the render function</p>
]]></description><link>https://forum.magicmirror.builders/post/21342</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/21342</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Tue, 09 May 2017 09:20:19 GMT</pubDate></item><item><title><![CDATA[Reply to Alert from inside function on Tue, 09 May 2017 07:48:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/strawberry-3.141" aria-label="Profile: strawberry-3.141">@<bdi>strawberry-3.141</bdi></a> Thanks that did the trick.</p>
]]></description><link>https://forum.magicmirror.builders/post/21337</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/21337</guid><dc:creator><![CDATA[Luukth]]></dc:creator><pubDate>Tue, 09 May 2017 07:48:40 GMT</pubDate></item><item><title><![CDATA[Reply to Alert from inside function on Mon, 08 May 2017 18:28:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/luukth" aria-label="Profile: Luukth">@<bdi>Luukth</bdi></a> thats an issue of accessing the right scope, you can fix that by using an arrow function</p>
<pre><code>setInterval(() =&gt; {
  updateOV();
  this.sendNotification("SHOW_ALERT", {title: "OV", message: "Bustijden ge-update.", timer: "1000"});
}, 10000);
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/21315</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/21315</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Mon, 08 May 2017 18:28:02 GMT</pubDate></item></channel></rss>