Ajax Not Found,asp.net mvc 中
x前台代码;
<script type="text/javascript"> $(document).ready(function () { $("#btnSub").click(function () { alert("点击!") $.ajax({ type: "POST", url: "/Home/btnSend_Click", data: { "send_to": "xx", "msg_send": "yy" }, success: function (sesponseTest) { alert(sesponseTest); $("#txt1").val(sesponseTest); }, error: function (XMLHttpRequest, textStatus, errorThrown) { $("#txt1").val(errorThrown); alert("保存失败:" + errorThrown); } }); }); }); </script>
x后端代码;
private ActionResult btnSend_Click(string send_to, string msg_send)//错误在这行,将private 改为public即可! { string ret_str = string.Empty; //do sth ... return Content(ret_str); }
但是一直提示:Not Found
即
一个是控制器内的方法关键字,用了privated,改为public;