我创建了一个web方法,现在我在我的java脚本文件中调用了它,但它给出了一个路径错误,它无法找到我要给的路径..C#Web方法不在javascript中调用
Web方法的代码是:
[System.Web.Services.WebMethod]
public static int ItemCount(string itemId)
{
int val = 0;
Item itm = Sitecore.Context.Database.GetItem(itemId);
val = itm.Children.Count;
return val;
}
Java脚本函数调用等为:
function GetItemCount(itemId) {
var funRes = "";
debugger;
try {
if (itemId != null) {
jQuery.ajax({
cache: false,
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Views/GetItem.aspx/ItemCount",
data: { itemId: itemId },
dataType: "json",
async: false,
success: function (data) {
funRes = data.result;
},
error: function(err) {
alert(err.responseText);
}
});
}
} catch (ex) {
alert(ex.message);
}
return funRes;}
而我给确切路径为C#方法类,但它不工作给出一个错误缺点ole,任何人都可以建议我什么,我在这里失踪..
从URL路径删除第一个斜杠(/)的Ajax和尝试 –
试过,解决不了我的问题 –
视图文件夹在sitecore文件夹中有什么? –