为什么我的“.asmx”不行? [英] why my ".asmx" not work?

查看:82
本文介绍了为什么我的“.asmx”不行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

请帮帮我

这是我的HTML代码:

 <   html     xmlns   =  http://www.w3.org/1999/xhtml < span class =code-keyword>>  
< head runat = 服务器 >
< script src = content / js / jquery-2.1.4.js > < / 脚本 >
< title > < / title >
< / head >
< 正文 >
< script type = text / javascript >
$( document)。ready(

$ .ajax(
{
类型: POST
url: test.asmx / sending
data: 'st:','sultan'
contentType: application / json
dataType: json
成功:accessfn,
错误:errfn
}



function accessfn(result){
alert(result.d);
}
function errfn(result){
alert(result.d);
}

< / script >
< 表格 id = form1 < span class =code-attribute> runat = server >
< asp:ScriptManager ID = ScriptManager1 runat = server >
< 服务 >
< asp:ServiceReference 路径 = 〜/ test。 asmx / >
< / Services >
< / asp:ScriptManager >
< / form >
< / body >
< / html >



,这是我的asp.net asmx文件:

 使用系统; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.Script.Services;
使用 System.Web.Services;

命名空间 didantest
{
///
/// didan $的摘要说明b $ b ///
[WebService(Namespace = http://tempuri.org/)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1) ]
[System.ComponentModel.ToolboxItem( false )]
// < span class =code-comment>要允许使用ASP.NET AJAX从脚本调用此Web Service,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class didan:System.Web.Services.WebService
{
[ScriptMethod]
[WebMethod]
public string sending( string st)
{
st = st + 宾果;
return st;
}
}
}



和result.d是未定义

为什么它不起作用?有什么问题?

谢谢

解决方案

document)。ready(


.ajax(
{
type: POST
url: test.asmx / sending
data: 'st: ','sultan'
contentType: application / json
dataType: json
成功:accessfn,
错误:错误
}



function accessfn(result){
alert(result) .D);
}
function errfn(result){
alert(result.d);
}

< / script >
< 表格 id = form1 < span class =code-attribute> runat = server >
< asp:ScriptManager ID = ScriptManager1 runat = server >
< 服务 >
< asp:ServiceReference 路径 = 〜/ test。 asmx / >
< / Services >
< / asp:ScriptManager >
< / form >
< / body >
< / html >



,这是我的asp.net asmx文件:

 使用系统; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Web;
使用 System.Web.Script.Services;
使用 System.Web.Services;

命名空间 didantest
{
///
/// didan $的摘要说明b $ b ///
[WebService(Namespace = http://tempuri.org/)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1) ]
[System.ComponentModel.ToolboxItem( false )]
// < span class =code-comment>要允许使用ASP.NET AJAX从脚本调用此Web Service,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class didan:System.Web.Services.WebService
{
[ScriptMethod]
[WebMethod]
public string sending( string st)
{
st = st + 宾果;
return st;
}
}
}



和result.d是未定义

为什么它不起作用?问题是什么?

谢谢


谢谢所有,它已经解决了:

 <   script    类型  =  text / javascript >  

hi all
please help me
it's my HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <script src="content/js/jquery-2.1.4.js"></script>
    <title></title>
</head>
<body>
    <script type="text/javascript">
        $("document").ready(
        
            $.ajax(
                {
                    type: "POST",
                    url: "test.asmx/sending",
                    data:"'st:','sultan'",
                    contentType: "application/json",
                    dataType: "json",
                    success: accessfn,
                    error: errfn
                }
                )
               
        )
        function accessfn(result) {
            alert(result.d);
        }
        function errfn(result) {
            alert(result.d);
        }

    </script>
    <form id="form1"  runat="server">
            "<asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/test.asmx" />
            </Services>
        </asp:ScriptManager>"
        </form>
        </body>
</html>


and it's my asp.net asmx file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;

namespace didantest
{
    /// 
    /// Summary description for didan
    /// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class didan : System.Web.Services.WebService
    {
        [ScriptMethod]
        [WebMethod]
        public string sending(string st)
        {
            st = st + "bingo";
            return st;
        }
    }
}


and result.d is "undefined"
why it's not working?what's the problem?
thanks

解决方案

("document").ready(


.ajax( { type: "POST", url: "test.asmx/sending", data:"'st:','sultan'", contentType: "application/json", dataType: "json", success: accessfn, error: errfn } ) ) function accessfn(result) { alert(result.d); } function errfn(result) { alert(result.d); } </script> <form id="form1" runat="server"> "<asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="~/test.asmx" /> </Services> </asp:ScriptManager>" </form> </body> </html>


and it's my asp.net asmx file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;

namespace didantest
{
    /// 
    /// Summary description for didan
    /// 
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class didan : System.Web.Services.WebService
    {
        [ScriptMethod]
        [WebMethod]
        public string sending(string st)
        {
            st = st + "bingo";
            return st;
        }
    }
}


and result.d is "undefined"
why it's not working?what's the problem?
thanks


thanks all,it's solved:

<script type="text/javascript">


这篇关于为什么我的“.asmx”不行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆