专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Web Service

webservice小疑点

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
webservice小问题
TestForm.aspx代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestForm.aspx.cs" Inherits="wt.TestForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jss/jquery.json-2.3.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function clickone() {
            var par = { str: "大家好!!!"};
            var json_str = $.toJSON(par);
            $.ajax({
                url: "TestData.asmx/HelloWorld",
                type:"POST",
                contentType:"application/json;charset=utf-8",
                dataType: "json",
                data:json_str,
                success: function (result) {
                    alret(result.d);
                }
            });
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="button" onclick="clickone()" value="one"/>
    </div>
    </form>
</body>
</html>


TestData.asmx代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace wt
{
    /// <summary>
    /// TestData 的摘要说明
    /// </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 TestData : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld(string str)
        {
            return "Hello World" + str;
        }
    }
}


为何点击“one”按钮没有反应???
webservice ajax

------解决方案--------------------
http://www.cnblogs.com/puresoul/archive/2010/08/19/1803567.html
------解决方案--------------------




        function clickone() {
            alert('检查是否执行了这里?');
            var par = { str: "大家好!!!"};
            var json_str = $.toJSON(par);
            $.ajax({
                url: "TestData.asmx/HelloWorld",
                type:"POST",
                contentType:"application/json;charset=utf-8",
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: