zoukankan      html  css  js  c++  java
  • .net webservers的使用

    添加一个webserver服务,保留原来的HelloWorld()方法并加入一个新的方法

           [WebMethod]
            public DataSet GetDs(int id)
            {
                DataSet ds = new BLL.TbMember().GetList(" ");
                return ds;
            }
    

     这样一个简单的web servers服务即可完成

    添加一个新的页面

    这里用ajax调用webservers的方法

     1 <script type="text/javascript">
     2         $(function () {
     3             $.ajax({
     4                 url: "WebService1.asmx/HelloWorld",
     5                 data: { ta: Math.random() },
     6                 success: function (data, textStatus) {
     7                     alert(data);
     8                 },
     9                 type: "post",
    10                 dataType: "text"
    11             });
    12 
    13             $.ajax({
    14                 url: "WebService1.asmx/GetDs",
    15                 data: { id: 1, ta: Math.random() },
    16                 success: function (data, textStatus) {
    17                     alert(data);
    18                 },
    19                 type: "post",
    20                 dataType: "text"
    21             });
    22 
    23             $.ajax({
    24                 url: "http://localhost:10097/WebService1.asmx/DL",
    25                 data: { user:'admin',ps:"123456", ta: Math.random() },
    26                 success: function (data, textStatus) {
    27                     alert(data);
    28                 },
    29                 type: "post",
    30                 dataType: "text"
    31             });
    32 
    33         });
    34     </script>

    说明:通过ajax调用webservers时候,写法参照上边代码,只可以使用post方式传递参数,参数名称需要和webservers上的方法参数名相同

    二、添加web服务引用

     添加一个名称是localhost的web服务引用后在使用的地方实例化即可,即:localhost.你的类

  • 相关阅读:
    三元运算符嵌套问题
    tp框架利用redis存储session
    PHP date('W')遇到跨年问题
    AES加解密 集成 spring MVC
    python SMTP 发送邮件
    mysql数据库安装过程
    (转)Apache启动过程
    apache服务器全局配置详解
    Apache 的 httpd.conf 详解(很实用)
    安装apache遇到的问题总结
  • 原文地址:https://www.cnblogs.com/netqq/p/2715046.html
Copyright © 2011-2022 走看看