Created
September 26, 2015 18:29
-
-
Save ceylonwebide/7addd309edaa56c5c2ef to your computer and use it in GitHub Desktop.
EXAMPLE: Interoperability 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$webrun_wrapped | |
shared void run() { | |
// Using JavaScript's XMLHttpRequest to connect | |
// to a simple web service that returns the time | |
// on the server and displays it in the console | |
dynamic { | |
print("Sending request..."); | |
dynamic req = XMLHttpRequest(); | |
req.onreadystatechange = void() { | |
if (req.readyState==4) { | |
print(req.status==200 | |
then "Time on server is: " + req.responseText | |
else "Received error: " + req.status); | |
} | |
}; | |
req.open("GET", "/time", true); | |
req.send(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment