MVC中ajax调用Controller的方法

1.

 1 ajax代码:
 2              $.ajax({
 3                     async: false,
 4                     cache: false,
 5                     type: 'POST',
 6                     contentType: "application/json",
 7                     url: "/MsgTypeTemItem/GetAllStr", //请求的action路径
 8                     data:{temId:$("#temId").val()},
 9                     error: function () {//请求失败处理函数  
10                         alert('请求失败');
11                     },
12                     success: function (data) { //请求成功后处理函数。    
13                         data = "[" + data + "]";
14                         treeNodes = eval(data);
15                     }
16                 });
17 Controller代码:
18 public string GetAllStr(string id)
19 {
20    List<MsgTypeTemItem> allList = msgTypeItemService.GetAll();
21     return "";
22 }

 

posted @ 2015-01-20 20:08  琅琊天  阅读(9389)  评论(0编辑  收藏  举报