[英]Ajax call doesn't hit the Server and returns HTML - ASP.NET MVC4
This is my server side code: 这是我的服务器端代码:
[HttpPost]
public bool mymethod()
{
bool success = false;
return success;
}
and this is the Ajax request I'm trying to make: 这是我要提出的Ajax请求:
$.ajax({
url:'mymethod',
type:'POST',
data:{},
success:function(data){console.log(data);},
error:function(data){console.log(data);},
})
Every time I make the request, it returns the complete HTML page (view) and never hits the Server method. 每当我发出请求时,它都会返回完整的HTML页面(视图),并且永远不会点击Server方法。 Please help. 请帮忙。
Thanks to Simon Whitehead for pointing out. 感谢Simon Whitehead指出。 I made the path relative and it worked: 我将路径设为相对路径,并且有效:
$.ajax({
url:'../mymethod',
type:'POST',
data:{},
success:function(data){console.log(data);},
error:function(data){console.log(data);},
})
Thanks again :) 再次感谢 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.