title: calling Golang functions from within javascript code
body: <p>I'm working on a webapp which already has a layout css, bootstrap v.3 along with an index.html. I have successfully loaded the project with Golang up and running. I have embedded a signup button which upon click is supposed to call a Go function from within the server.go file that handles http requests.</p>
  
  <pre><code>    $(document).ready(function() {
      $('#signup').on('click', loginHandler);
  });
  </code></pre>
  
  <p>I have a server.go file written like this:</p>
  
  <pre><code>package main
  
  import (
      "net/http"
  
      "github.com/bmizerany/pat"
  )
  
  func init() {
      m := pat.New()
  
      m.Get("/signup", http.HandlerFunc(loginHandler))
      m.Get("/", http.HandlerFunc(rootHandler))
      http.Handle("/", m)
  }
  
  func rootHandler(w http.ResponseWriter, r *http.Request) {
      http.ServeFile(w, r, r.URL.Path[1:])
  }
  
  func loginHandler(w http.ResponseWriter, r *http.Request) {
  
  }
  </code></pre>
  
  <p>So the question is upon click on an button instance with <em>signup Id</em>, how do I have to trigger the golang <em>loginHandler</em> function in server.go file?
  Any idea on this would be appreciated.</p>