GoRevelとAjaxとCSRF
Ajaxのレスポンスは、JSON
ときめたら、ControllerのRenderは、
func (c Post) GetAll() revel.Result { var po *models.Post posts := po.FindAll(c.Txn) response := make(map[string]interface{}) response["posts"] = posts return c.RenderJson(response) }
のようにした。
検索結果をmapに押し込んでいるのは、他の検索結果が必要な時に、一気に送りこむ魂胆。
RenderJsonに、カンマ区切りでもできんのかなぁ?・・・未検証。
AJAX側では、(注意:coffeescript)
successGetAllPost = (datas, textStatus, jpXHR) -> unless textStatus is "success" alert("現在、調整中です。時間を置いて再度ご利用下さい。") return # alert(datas.toSource()) posts = datas.posts
見たいにすれば、大丈夫。
これで、地図に反映させる。