日期:2014-05-17  浏览次数:20798 次

jQuery ajax

 if (nameold != option.value) {
                    nameold = option.value;
                    option.errorEle.html("<span style='color:#999'>检验中……</span>");
                  $.getJSON("AjaxService.aspx?uid=" + escape(option.value) + "", function (date) {
                        if (date.success == 0) {
                            validateSettings.succeed.run(option);
                            namestate = true;
                        } else {
                            validateSettings.error.run(option, option.prompts.error.beUsed.replace("{1}", option.value));
                            namestate = false;
                        }
                    })
                }
                else {
                    validateSettings.error.run(option, option.prompts.error.beUsed.replace("{1}", option.value));
                    namestate = false;
                }

想实现的结果是注册页面中输入会员名无刷新检验是否存在。现在我新建了AjaxService.aspx在.cs页面中获取到了该会员名,并在数据库中查找是否存在,但怎么实现查找结果返回来这个页面,有就执行validateSettings.error.run(option, option.prompts.error.beUsed.replace("{1}", option.value));
                            namestate = false;
没有就执行 if (date.success == 0) {
                            validateSettings.succeed.run(option);
                            namestate = true;

AjaxService.aspx.cs的代码

 public partial class AjaxService : System.Web