[英]How to add Webmethod in “Dynamic Data” on ASP.net with c#
[WebMethod(EnableSession = true)]
public static string SaveFavourites(string id, bool check)
{
//My Code here
}
This method is inside Dynamic Data folder(DynamicData/CustomePages/Products). 此方法位于“动态数据”文件夹(DynamicData / CustomePages / Products)中。 I just trigger ajax call to this method.
我只是触发对此方法的ajax调用。
Unfortunatly its not working. 不幸的是,它无法正常工作。 Its return me "404 Not found"
它返回我“ 404未找到”
Here my ajax CALL. 这是我的Ajax CALL。
$.ajax(
{
type: "POST",
url: "List.aspx/SaveFavourites",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
data: { "id": productID, "chkboxValue": chkboxValue },
success: function (result) {
alert(result);
}
});
Please Help at the earliest. 请尽早提供帮助。
It seems you are putting incorrect url in jquery ajax call. 看来您在jquery ajax调用中输入了错误的url。
Is your page, where you have written jquery ajax call, is under DynamicData/CustomePages/Products? 您编写jquery ajax调用的页面是否在DynamicData / CustomePages / Products下? If yes then your url is correct otherwise you have to put correct url.
如果是,则您的网址正确,否则您必须输入正确的网址。
HINT : use relative path. 提示:使用相对路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.