首页 > Web开发 > 详细

最简单的ajax调用webservice

时间:2014-04-23 22:36:06      阅读:609      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<%@ 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>
bubuko.com,布布扣
bubuko.com,布布扣
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";
        }
    }
}
bubuko.com,布布扣

 

最简单的ajax调用webservice,布布扣,bubuko.com

最简单的ajax调用webservice

原文:http://www.cnblogs.com/hellolong/p/3679400.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!