C# jsTree 3.0.2-如何将参数传递给aspx webmethod
我试图将jsTree 3.0.2中的一个参数传递给aspx页面上的web方法,但它没有命中web方法。但是,当没有参数时,它确实起作用。有人能指出我的错误吗 带参数(不工作):C# jsTree 3.0.2-如何将参数传递给aspx webmethod,c#,asp.net,web-services,jstree,C#,Asp.net,Web Services,Jstree,我试图将jsTree 3.0.2中的一个参数传递给aspx页面上的web方法,但它没有命中web方法。但是,当没有参数时,它确实起作用。有人能指出我的错误吗 带参数(不工作): [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static IEnumerable<JsTreeNode> GetAll(string id) { // method does not get calle
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// method does not get called
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
'data': function (node) {
return { 'id': "01" };
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
// successfully calls method
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) { return {}; }
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// success!
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) {
return '{ "id" : "01" }';
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll(字符串id)
{
//方法未被调用
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:函数(节点){
返回{'id':“01”};
}
}
}
});
无参数(工作):
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// method does not get called
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
'data': function (node) {
return { 'id': "01" };
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
// successfully calls method
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) { return {}; }
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// success!
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) {
return '{ "id" : "01" }';
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll()
{
//成功调用方法
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:函数(节点){return{};}
}
}
});
谢谢。找到了问题。应该是:
return '{ "id" : "01" }';
工作代码:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// method does not get called
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
'data': function (node) {
return { 'id': "01" };
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll()
{
// successfully calls method
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) { return {}; }
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IEnumerable<JsTreeNode> GetAll(string id)
{
// success!
}
$("#jsTreeTest").jstree({
"core": {
"data": {
"url": "MyPage.aspx/GetAll",
"type": 'POST',
"dataType": 'JSON',
"contentType": 'application/json;',
"data": function (node) {
return '{ "id" : "01" }';
}
}
}
});
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
公共静态IEnumerable GetAll(字符串id)
{
//成功!
}
$(“#jsTreeTest”).jstree({
“核心”:{
“数据”:{
“url”:“MyPage.aspx/GetAll”,
“类型”:“职位”,
“数据类型”:“JSON”,
“contentType”:“application/json;”,
“数据”:功能(节点){
返回“{”id:“01”}”;
}
}
}
});