// AJAX Request Handler
func ajaxHandler(w http.ResponseWriter, r *http.Request) {
//parse request to struct
var d Data
err := json.NewDecoder(r.Body).Decode(&d)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// create json response from struct
a, err := json.Marshal(d)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
w.Write(a)
}
w.Write(a)
.