Database access from index.html template


Is it possible to have read/write access to an external database from the index.html template?


Hi @nigelibrown,

it is possible, but is not implemented by our z.js library, so you would need to do that with JS code.
What external database would you like to access?


We are looking to store a small number of values in a database and access them in the template using, the following. However we have had no success. After some research it would seem that the database has to be on the same server or the browser will not allow access? Can you offer any suggestions?

// POST data to database.
var http = new XMLHttpRequest();
var url = “”;
var params = "msg=0: "+formatDate(now);“POST”, url, true);
http.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
http.setRequestHeader(“Content-length”, params.length);
http.setRequestHeader(“Connection”, “close”);
http.onreadystatechange = function() {//Call a function when the state changes.
if(this.readyState == 4 && this.status == 0) {