当前位置:首页>开发>正文

Asp.NetMVC的ContentResult返回字符串,jquery.post的回调函数不接受,为什么

2023-06-16 20:47:46 互联网 未知 开发

Asp.NetMVC的ContentResult返回字符串,jquery.post的回调函数不接受,为什么?

Asp.NetMVC的ContentResult返回字符串,jquery.post的回调函数不接受,为什么

因为你返回的是字符串"success",对于$.post来说,数据类型应该是html。但是你定的$.post数据类型是json。

要么把$.post最后的"json"去掉

要么return Json(new {result = "success"}),然后在$.post里面用response.result 获取返回值。

最新文章