码迷,mamicode.com
首页 > 其他好文 > 详细

Ajax请求C#后台某个方法

时间:2014-08-22 14:24:58      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   os   io   ar   art   

前台:
 
bubuko.com,布布扣
 1 $.ajax({
 2     url: "TransBloodRequisition.aspx/aaa",//页面后台带方法名
 3     contentType: "application/json",//必须为application/json
 4     type: "POST",//必须为POST
 5     data: "{  }",//格式为 "{a:1,b:2}"
 6     dataType: "json",//必须为json
 7     success: function (result) {
 8     alert(result.d)
 9     }
10     })
View Code

 

后台:
 
bubuko.com,布布扣
1  [WebMethod(EnableSession= true)]
2         public static string aaa()
3         {
4             return "bb" ;
5         }
View Code

 

//EnableSession= true 使用session
//有参数时 后台参数名称和前台传的参数必须一致,顺序可以不一致

Ajax请求C#后台某个方法

标签:style   blog   http   color   使用   os   io   ar   art   

原文地址:http://www.cnblogs.com/quexianwei/p/3929173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!