当前位置:编程学习 > JS >>

jquery ajax 没有返回值的解决方法

 代码如下 复制代码

//添加async:false.即修改为同步
//
 function vcodeYes() {
        var bol = false;
        $.ajax(
    {
        type: "GET",
        url: "../Ajax/ValidationCode.ashx",
        data: { txtVcode: $('#<%=txtVcode.ClientID%>').val() },
        async: false,
        success: function (data) {
            if (data == "0") {
                $.dialog({ icon: 'warning', follow: document.getElementById('txtVcode'), content: '验证码错误!' }).time(1);
                changeCaptchaImage('imgVerify2', 'txtVcode');
            }
            else {
                bol = true;
            }
        }
    });
        return bol;
    }

//验证没通过是 返回false 否则执行下面函数
 $('.getVodes').click(function () {
       if (vcodeYes()) {
                。。。执行下面。。。
              }

  });

补充:网页制作,jquery 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,