Copy link to clipboard
Copied
My HTML5 Canvas needs to check for user authentication, so it queries an asp script for a session status result (just a simple string). But I am not able to get it to work. I have created a simple testing asp script:
<%
response.write "GOT_HERE"
%>
I can confirm this script returns 'GOT_HERE' to the screen when loaded directly in the browser.
I attempt to query it in my canvas via:
$('#dom_overlay_container').on('click', '#button1', function() {
this.myDynText.text = "Step 1";
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
this.myDynText.text = "Step 2";
if (this.readyState == 4 ) {
this.myDynText.text = this.responseText;
}
};
xhttp.open("GET", "TEST.asp", true);
xhttp.send();
}.bind(_this));
I successfully get to Step 1, but not Step 2. Any idea what's wrong?
Thanks,
Geoff
Copy link to clipboard
Copied
I found the problem! In my funciton,
this.myDynText.text
should be
_this.myDynText.text
Geoff
Copy link to clipboard
Copied
Would anyone have a moment to explain why? I don't understand the scope of this, _this, that, etc.
Thanks,
Geoff