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";
            }
        }
    }
  • 相关阅读:
    23.Java函数
    22.java中的break和continue关键字
    21.Java中for循环
    20.java中的while循环
    19.java中选择判断语句(switch)
    18.java中判断(if…else)
    17.java运算符的优先级与结合性
    16.Java三元运算符
    数组去重
    数组 字符串 对象 常用方法
  • 原文地址:https://www.cnblogs.com/hellolong/p/3679400.html
Copyright © 2011-2022 走看看