ajaxTest.aspx 中 <input type="text" id="txtCategoryName" runat="server" />ajaxTest.aspx.cs中 
    protected void Page_Load(object sender, EventArgs e)
    {
        AjaxPro.Utility.RegisterTypeForAjax(typeof(ajaxTest));
    }
    /// <summary>
    /// 判断用户名是否存在
    /// </summary>
    /// <param name="Name"></param>
    /// <returns></returns>
    [AjaxPro.AjaxMethod]
    public bool JugeCategoryName(string Name)
    {
        //////
    }AddCategory.js中
$(document).ready(function(){    //分类名验证
   $("#txtCategoryName").bind("blur",function(){
        var $parent=$(this).parent();
        var str= $.trim($(this).val());
        alert(str);
        $parent.find(".formtips").remove();
        var CategoryJuge=ajaxTest.JugeCategoryName(str);
        }); 
});
在线等,求求好心人帮忙

解决方案 »

  1.   

    js 调用AjaxPro.AjaxMethod 方法应是 你的命名空间.ajaxTest.JugeCategoryName(参数).value
      

  2.   

    那你家断点看看 能执行到JugeCategoryName()方法吗
    如不能 就是你 js写错了在你的web.config 中 要配置 ajaxpro
      

  3.   

    我按网上的步骤配置了webconfig
    JugeCategoryName,前面一句还能执行,就是掠过了JugeCategoryName()这个方法
      

  4.   

    是js 中前面一句能执行 吗
    JugeCategoryName()这个方法 执行不到吗
    如果是 那就是你调用后台方法时出错了 
    ajaxTest.JugeCategoryName(str); 出错了  我在用的时候都是 命名空间.ajaxTest.JugeCategoryName(参数).value 这样用的
      

  5.   

    前面能执行,我加了alert
    就是后台没调用到
    我没声明命名空间,那我该怎么引用.ajaxTest.JugeCategoryName(参数).value 
      

  6.   

    我把我三个文件全贴出来吧,希望大哥帮我看看ajaxTest.aspx<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <script src="JS/jquery-1.3.2.js" type="text/javascript"></script>
        <script src="JS/AddCategory.js" type="text/javascript"></script>
        <title>无标题页</title>
    </head>
    <body>
        <div class="right_title">
    <img alt="" src="Images/fy_003.gif" width="4" height="29" />
    <h2>当前位置:后台管理系统 >分类管理 ><a>分类添加</a> </h2>
    <span><img alt="" src="Images/fy_002.gif" width="4" height="29" /></span>
    <div class="null"></div>
          </div>
    <div class="right_content">
    <form runat="server" id="form1">
    <table border="0" cellpadding="0" cellspacing="0" class="right_content_whole">
    <tr>
    <td class="table_name">分类名称:</td>
    <td class="table_content">
                                <input type="text" id="txtCategoryName" runat="server" />
    </td>
    </tr>



    <tr>
    <td class="table_name"></td>
    <td class="table_content">
    <div class="content_submit">
                                    <asp:ImageButton ID="ibtnAdd"  runat="server"  Width="108" Height="27"
                                ImageUrl="Images/fy_19.jpg" OnClick="ibtnAdd_Click" OnClientClick="return CheckForm();" />
    </div>
    </td>
    </tr>
      </table>
      </form>
      </div>
    </body>
    </html>
      

  7.   

    ajaxTest.aspx.cs
    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;public partial class ajaxTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {        }
            AjaxPro.Utility.RegisterTypeForAjax(typeof(ajaxTest));
        }
        /// <summary>
        /// 判断用户名是否存在
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public bool JugeCategoryName(string Name)
        {
            Core.SP<QueryParam.Category, Model.Category> usp = new Core.SP<QueryParam.Category, Model.Category>();
            usp.QueryParam.CategoryName = txtCategoryName.Value.Trim();//用户名
            Core.Result<Model.Category> uspResult = usp.Run("IsExists");
            if (uspResult.ErrorCode == 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 添加分类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ibtnAdd_Click(object sender, ImageClickEventArgs e)
        {        if (!string.IsNullOrEmpty(txtCategoryName.Value.Trim()))
            {
                Core.SP<QueryParam.Category, Model.Category> usp = new Core.SP<QueryParam.Category, Model.Category>();
                usp.QueryParam.CategoryName = txtCategoryName.Value.Trim();
                usp.ShowColumns = "CategoryName";
                Core.Result<Model.Category> uspResult = usp.Run("AddCategory");
                if (uspResult.ErrorCode == 0)
                {
                    CommonMethod.Alert("添加成功!");
                }
                else
                {
                    CommonMethod.Alert(uspResult.ErrorMessage);
                }
            }
        }
    }
      

  8.   

     js 文件中看str有没值 
    web.config 配置
    <httpHandlers>
          <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
    </httpHandlers>
      

  9.   

    根据我用ajaxpro的经验,没效果说明ajaxmethod的方法有问题,如果你用IE,可以看到左下角有脚本错误提示,建议对后台方法捕捉一下异常,然后将结果作为调用方法的value传到前台检查一下。还有类名是你当前页面的类名。。