[英]Go - How to receive json data which ajax type is DELETE using gin
我正在制作Web應用程序。 但是我有一個大問題。 在后端,我做了DELETE的功能。
這是DELETE函數:
router.DELETE("/rsv/delete", func(c *gin.Context) {
//how to receive json data?
})
然后我通過Ajax發送json數據。
這是Ajax函數:
$.ajax({
url: "/rsv/delete",
type: "DELETE",
data: parse_delete,
contentType: "application/json",
success: function(result) {
if (result) {
alert("삭제가 완료되었습니다!");
location.href = "/member_index";
}
else {
alert("Error");
}
}
})
請幫我。
您可以嘗試BindJson
的方法gin.Context
。
var json SomeJsonStruct
if c.BindJSON(&json) == nil {
//...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.