[英]Go - How to receive json data which ajax type is DELETE using gin
I'm making web application. 我正在制作Web应用程序。 But I conflict big problem. 但是我有一个大问题。 In back-end, I made function for DELETE. 在后端,我做了DELETE的功能。
Here is DELETE function : 这是DELETE函数:
router.DELETE("/rsv/delete", func(c *gin.Context) {
//how to receive json data?
})
And I send json data by Ajax. 然后我通过Ajax发送json数据。
Here is Ajax function : 这是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");
}
}
})
Please Help me. 请帮我。
You may try BindJson
method of gin.Context
. 您可以尝试BindJson
的方法gin.Context
。
var json SomeJsonStruct
if c.BindJSON(&json) == nil {
//...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.