2014-07-24 1 views
3

jsTree 3.0.2의 매개 변수를 aspx 페이지의 웹 메서드로 전달하려고 시도하고 있지만 웹 메서드가 작동하지 않습니다. 그러나 매개 변수가 없을 때 작동합니다. 아무도 내 방식의 오류를 지적 할 수 있습니까? 매개 변수와jsTree 3.0.2 - aspx webmethod에 매개 변수를 전달하는 방법

(작동하지 않는) : 매개 변수없이

[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 {}; } 
     } 
    } 
}); 

감사합니다.

답변

3

발견. 그것은해야한다 :

return '{ "id" : "01" }'; 

작업 코드 :

[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" }'; 
      } 
     } 
    } 
});