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);
            }
  • 相关阅读:
    我们应该如何防范黑客的攻击? 有哪些棘手问题?
    德国网络安全公司Avira被收购,估值为1.8亿美元
    物联网会成为黑客攻击的目标,智慧城市如何才安全?
    因新型冠状病毒,笔记本电脑销售增长,人们寻求更好的设备进行远程工作
    从电脑维修工到互联网大佬,他是怎么做到的?解读郭盛华最真实的传奇生涯
    企业防御网络风险保护计划的5个步骤
    加载失败图片加样式
    请求接口无权限
    iview button根据条件 disabled可用或者不可用
    vue跨组件传值
  • 原文地址:https://www.cnblogs.com/sig556/p/1579581.html
Copyright © 2011-2022 走看看