webservice
    [WebMethod]
    public int checkIshege(int fid)
    {
        int n = 0;
        StringBuilder Str = new StringBuilder();
        Str.Append("Update RM_Admin_Work");
        Str.Append(" set [Ishege]=@Ishege");        SqlParameter[] parameters ={
                                  new SqlParameter("@Ishege",SqlDbType.Int,4)
                                  };        parameters[0].Value = fid;
        RM.DataProvider.SqlDBO db = new SqlDBO();
        n = db.execnonsql_ExecuteNonQuery(Str.ToString(), parameters);
        return n;
        
    }
js        function NotAwards(id) {
            alert(id);
            $.ajax({
                type:"post",
                contentType:"text",
                url:"/WebService/check.asmx/checkIshege",
                data:"{'fid':'" + id + "'}",
                success:function() {                }
            });
     
        }
这个id可以alert的出来,我上面的checkIshege这个方法加了断电,但是 调试的就是跳不同过来怎么回事大侠

解决方案 »

  1.   

    webservice 不是这么调用 的
      

  2.   

     public int checkIshege(int fid)改成public static int checkIshege(int fid)jquery ajax 只能调用static修饰的方法
      

  3.   

    同时先确认 在ie中 /WebService/check.asmx 是可访问的。
      

  4.   

    再问下,ajax页面 和 webservice页面是否是跨域访问?
      

  5.   

    你这样试下,
    将你的 [WebMethod] 方法移到ajax的这个页面,并用state修饰,看下能否调用
      

  6.   

    页面
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="Magic.PartySystem.UI.Pages.WebForm3" %><!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="../Script/jquery-1.6.2.min.js" type="text/javascript"></script>
    </head>
    <body>
    <script>
        function callweb()
        {alert(2);
            $.ajax({
                type: "post",
                contentType: "application/json",
                url: "WebForm3.aspx/checkIshege",
                data: "{'fid': 12}",
                success: function ()
                {
                    alert(1);
                }
            });
        }
    </script>
        <form id="form1" runat="server">
        <div>
            <input type="button" onclick="callweb()" value="call" />
        </div>
        </form>
    </body>
    </html>cs文件
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Services;namespace Magic.PartySystem.UI.Pages
    {
        public partial class WebForm3: Page
        {
            protected void Page_Load( object sender, EventArgs e )
            {        }        [WebMethod]
            public static void checkIshege( int fid )
            {
                string a = "asdfa";
            }
        }
    }
      

  7.   

    首先JQ是可以支持跨域调去的,但配置比较麻烦,容易出错,而且不便于管理。
    然后,JQ调用WebService最后加上Content-Type:application/json;utf-8属性,因为默认的JQ不知道是什么处理方式。然后记得在输出的Success函数里进行数据转换,例如var json = eval('(' + msg + ')');
      

  8.   

    新对跨域的支持很好 否则wcf调用就是个大问题
      

  9.   

    你这样写        }
    改成
               $.ajax({
                    type:"post",
                    contentType:"json",
                    dataType:"application/json;charset=uft-8"
                    url:"/WebService/check.asmx/checkIshege",
                    data:"{'fid':'" + id + "'}",
                    success:function(reuslit) {
    alert(result.d)                }
                });
    一定要加个d。放回值
      

  10.   

    刚刚有个地方写错了,还不让编辑,重新写下,用这个
    你这样写  }
    改成
      $.ajax({
      type:"post",
      contentType:"json",
      dataType:"application/json;charset=uft-8"
      url:"/WebService/check.asmx/checkIshege",
      data:"{fid:" + id + "}",
      success:function(reuslt) {
    alert(result.d)  }
      });
    一定要加个d。放回值
      

  11.   

    无语。result拼写错误。楼主自己改写吧。我才来,对这个编辑功能不熟悉