It is really cool to run Go code in the browser. GopherJS is a compiler from
In this post, we will show how to make cross-domain requests (CORS) by JSONP
(JSON with Padding) technique, which allows data to be retrieved from servers of
This is an example of full-stack Go, which uses Golang to develop web
applications in both front-end (runs on browsers) and backend (runs on servers).
First we write a simple HTML for our demo: (index.html)
<!doctype html><html><head><title>JSONP example of Full-Stack Golang</title></head><body><scriptsrc="demo.js"></script></body></html>
A callback function whose name is mycallback are declared by js.Global.Set
method. The mycallback function will receive JSON data from the server.
Beside, a script element are inserted to the head element to make