Skip to content

Instantly share code, notes, and snippets.

@ceylonwebide
Created September 26, 2015 18:29
Show Gist options
  • Save ceylonwebide/7addd309edaa56c5c2ef to your computer and use it in GitHub Desktop.
Save ceylonwebide/7addd309edaa56c5c2ef to your computer and use it in GitHub Desktop.
EXAMPLE: Interoperability 2
//$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