We're on GitHub


QuickerSite is available on GitHub as from 2020.

You may want to star, fork, follow, download and/or contribute to the project over there. Thank you!

Login Contact

to Developers Blog

My JavaScript crash courses over the past few weeks are paying off already. Tonight, I was asked to include a JSON calendar for a website I host for quite a while now.

I took the challenge and I was succesful with the script below:

<script>
var x;
var xmlhttp = new XMLHttpRequest();
xmlhttp.[onreadystatechange] = function() {
    if (this.readyState == 4 && this.status == 200) {
        var myObj = JSON.parse(this.responseText);

for(var i = 0; i < myObj.data.length; i++) {
    var obj = myObj.data[i];

x=x+ "<tr>";
x=x+ "<td>" + obj.date.dayName + " " + obj.date.day + "/" + obj.date.month + "/" + obj.date.year + "</td>";
x=x+ "<td colspan=3><strong>" + obj.eventName + "</strong>";

if (obj.tickets != null ) {
x=x+ " - <strong><a target='_blank' style='color:#F49021' href='" + obj.tickets.url + "'>tickets</a></strong>"

};

x=x+ "</td></tr>"
x=x+ "<tr><td style='font-size:0.8em'>("+  obj.performanceTime + ")</td>";
x=x+ "<td>" + obj.venue.name + " - " + obj.venue.street + " - " + obj.venue.city + " (" + obj.venue.countryCode + ")</td></tr>";
x=x+ "<tr><td style='height:20px'> </td></tr>";

}

document.getElementById("demo").innerHTML = "<table cellpadding=5 border=0>" + x.replace("undefined","") + "</table>";
    }
};
xmlhttp.open("GET", "/storeJSON.asp", true);
xmlhttp.send();

</script>
<div id="demo"> </div>

The most important line is xmlhttp.open("GET", "/storeJSON.asp", true);
The actual JSON is NOT located on that particular website. It rarely is. JSON is made to transfer data from site to site, server to server. But my storeJSON.asp looks like this:

<%

dim aj_XmlHttp,inputsource
Set aj_XmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
aj_XmlHttp.open "GET", "https://XXXXXXXXXXXXX", False
aj_XmlHttp.setRequestHeader "Content-Type", "text/json"
aj_XmlHttp.setRequestHeader "CharSet", "UTF-8"
aj_XmlHttp.Send
inputsource = aj_XmlHttp.responseText
set aj_XmlHttp = Nothing

response.write inputsource

%>

where XXXXXXXXXXXXX is the actual URL with JSON data to be parsed. UC? Handy. And even though the big load is on the client here, the actual JSON-URL is not exposed in the browser. Oh btw, it's all about this page.

to Developers Blog

© QuickerSite webCMS 2020

backtotop