AJAX通话-找不到404 [英] AJAX call - 404 Not Found
本文介绍了AJAX通话-找不到404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过AJAX在服务器端调用一个函数.用户/模块内部包含的connect_v2.ascx文件内部的函数.这是我的通话代码:
I'm trying to call a function on the server side through AJAX. The function inside connect_v2.ascx file which is contained inside user/module. Here's my code for the call :
function Request() {
$.ajax({
type: "POST",
url: '<%= ResolveUrl("~/user/modules/connect_v2.ascx/Follow") %>',
data: "{}",
contentType: "application/json",
success: function (msg) {
}
});
}
我的服务器端功能如下:
My server side function is as follows :
[WebMethod]
public static void Follow()
{
}
我收到404 Not Found错误,这表示我没有提供正确的网址.有人可以帮我看看我在做什么错吗?
I get 404 Not Found error which means I'm not providing a correct url. Can anyone please help me see what I'm doing wrong here?
推荐答案
在ascx
中不能包含WebMethod
.更好的解决方案是创建asmx
并在其中写入WebMethod
.
You can not have WebMethod
inside ascx
. Better solution would be create asmx
and write WebMethod
there.
这篇关于AJAX通话-找不到404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文