zoukankan      html  css  js  c++  java
  • webservice调用

    1.后台调用.net webservice,只需要引用生成一个代理类即可。
    2.前台调用.net webservice:
    使用jquery:

      //                $.ajax({
                    //                    url: "http://localhost:7916/webservicetest.asmx/HelloWorld",
                    //                    dataType: "json",
                   //     contentType: "application/json",
                    //                    type: "post",
                    //                    async: true,
                    //                    cache: false,
                    //                    data: "",
                    //                    beforeSend: function() { },
                    //                    success: function(data, textStatus) {
                    //                        alert(data.d);
                    //                    },
                    //                    error: function(result, status) {
                    //                        if (status == 'error')
                    //                            alert(status);
                    //                        alert(result);
                    //                    }

                    //                });
    返回json格式数据必需加 contentType: "application/json", 返回是data.d
    3.使用脚本:
    后台增加
    using System.Web.Script.Services;
        [ScriptService]
    前台增加
       <asp:ScriptManager ID="ScriptManager" runat="server">
            <Services>
                <asp:ServiceReference InlineScript="true" Path="~/WebServiceTest.asmx" />
            </Services>
        </asp:ScriptManager>
    前台直接调用:
      FastPower.Web.WebServiceTest.HelloWorld(onresult);

    由onresult函数去处理
      function onresult(result) {
                alert(result);
            }
  • 相关阅读:
    jquery引入页面公共部分
    webpack1:安装webpack及项目创建
    windows命令中的cd
    区分IE8 、IE9 、IE10的专属css hack
    HSLA色相饱和透明度
    jquery开关按钮效果
    Jquery样式
    CSS文本溢出显示省略号
    数组重排
    webstorm node 3000端口被占用
  • 原文地址:https://www.cnblogs.com/sig556/p/1579581.html
Copyright © 2011-2022 走看看