zoukankan      html  css  js  c++  java
  • 最简单的ajax调用webservice

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestHelloWorld.aspx.cs" Inherits="AjaxWebservice.TestHelloWorld" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:ScriptManager ID="sm1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/selfWS.asmx" />
            </Services>
        </asp:ScriptManager>
        </div>
            <script type="text/javascript">
                AjaxWebservice.selfWS.HelloWorld(OnRequestComplete);
                    function OnRequestComplete(result) {
                        alert(result);
                    }
        </script>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace AjaxWebservice
    {
        /// <summary>
        /// selfWS 的摘要说明
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 
        [System.Web.Script.Services.ScriptService]
        public class selfWS : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
        }
    }
  • 相关阅读:
    NetCore
    OAuth授权
    Vue混入:全局混入
    Vue作用域插槽:用作循环结构的模版
    Vue作用域插槽:基本用法
    Effect Hook
    State Hook
    表单组件中state依赖props
    Vue自定义指令
    Vue访问子组件实例或子元素
  • 原文地址:https://www.cnblogs.com/hellolong/p/3679400.html
Copyright © 2011-2022 走看看