Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload=function(){
- var canvas= document.getElementById('myCanvas'); // left it here for you
- console.log(" client loaded");
- canvas.addEventListener('mousedown',askForData,false);
- var arrayBuffer = "";
- var id = setInterval(runLoop,10);
- function runLoop(){
- var ctx=canvas.getContext('2d');
- ctx.fillStyle = "green";
- ctx.fillRect(0,0,canvas.width,canvas.height);
- if (arrayBuffer === ""){
- ctx.fillStyle = "black";
- ctx.fillText("No Message Yet",30,30);
- }
- else {
- ctx.fillStyle="black";
- ctx.fillText(arrayBuffer.name,30,30);}
- }
- function askForData(){
- function doSomethingWithData(){
- var tempBuffer = dataRequest.responseText;
- console.log(tempBuffer);
- arrayBuffer = JSON.parse(tempBuffer); // turns my data into accessible data
- console.log(arrayBuffer);
- }
- var dataRequest = new XMLHttpRequest();
- dataRequest.addEventListener('load',doSomethingWithData);
- dataRequest.open('GET','/GetSomeData');
- dataRequest.send();
- }
- } // end of window onload - never delete this one!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement