$.ajax success callback not firing in firefox

I'm having an issue where my call to $.ajax is completing successfully and returning content with a response of 200OK as reported by firebug, but the success,complete and error callbacks do not execute. This is only happening in firefox, in chrome it works fine (i am running firefox22).

$.ajax(site_url+url+'/fetch_salt',{type:'POST',data:data,success:check_salt});
var group = '';

function check_salt(d)
{
    console.log(d);

The actual response for the request as reported by firebug is:

choose_login:{"admin":"Admin Zone"}

And response type:

Content-Type    text/html

I have tried forcing settings like dataType and contentType in case jquery is assuming json or something and I have tried anonymous functions for the error, success and complete callbacks, but nothing works.

Am posting full function code, just in case its some kind of syntax error quirk:

function prep_login_form(elem,url,challenge)
{
    function show_error(msg)
    {
        $(elem).find('.ecms-error-for-password .ecms-error-text').html(msg).closest('.ecms-error-container').removeClass('ecms-error-hidden');
    }

    function submit()
    {
        var data = {email:$(elem).find('input[name="email"]').val()};
        data[csfr_token_name] = csfr_hash;
        $.ajax({type:'POST',url:site_url+url+'/attempt_login',data:data,success:check_salt});
        var group = '';

        function check_salt(d)
        {
            console.log(d);
            if (d=='no_email')
            {
                show_error('Invalid Email address');
            }
            else if (d=='account_disabled')
            {
                show_error('This account has been disabled, please contact your administrator');
            }
            else if (d.substr(0,12)=='choose_login')
            {
                var cl;
                eval('cl = '+d.substr(13));
                var cou = 0;
                for (p in cl)
                {
                    cou++;
                }
                if (cou==1)
                {
                    group = p;
                    var mydata = $.extend(data,{group:p});
                    $.ajax(site_url+url+'/fetch_salt',{type:'POST',data:mydata,success:check_salt})
                }
                else
                {
                    var str = '<div class="login-selection-popup"><p>We have detected that your email address is linked to more than one account.<br />Please select which zone you would like to login to.</p><ul class="choose-login-popup">';
                    for (p in cl)
                    {
                        str+='<li><a rel="'+p+'">'+cl[p]+'</a></li>';
                    }
                    str+='</ul></div>';
                    open_modal({heading:'Choose Account',content:str,buttons:function(close_modal)
                    {
                        $(this).find('.choose-login-popup').on('click','a',function()
                        {
                            group = $(this).attr('rel');
                            var mydata = $.extend(data,{group:$(this).attr('rel')});
                            $.ajax(site_url+url+'/fetch_salt',{type:'POST',data:mydata,success:check_salt})
                            close_modal();
                        });
                    }});
                }
            }
            else
            {
                var salt = d;
                var pw = $(elem).find('input[name="password"]').val();
                data.password = hex_md5(challenge+hex_md5(salt+pw));
                data.group = group;
                $.ajax(site_url+url+'/attempt_login',{type:'POST',data:data,success:function(d)
                {
                    if (d=='no_email')
                    {
                        show_error('Invalid username or password');//Invalid Email address
                    }
                    else if (d=='account_disabled')
                    {
                        show_error('This account has been disabled, please contact your administrator');
                    }
                    else if (d=='invalid_login')
                    {
                        show_error('Invalid username or password');//Email or Password did not match
                    }
                    else
                    {
                        window.location.href = d;
                    }
                }});
            }
        }
    }

    $(elem).on('keyup','input',function(e)
    {
        if (e.keyCode=='13')
        {
            submit();
        }
    });
    $(elem).find('.login-submit').on('click',function()
    {
        submit();
    });
}

Sorry for all the trouble guys I recently had addware on my PC and battled to get rid of it. I think that it had damaged/hijacked my firefox. After re-installing firefox the problem has gone away, the callbacks now execute.

链接地址: http://www.djcxy.com/p/96482.html

上一篇: 如何从数据中获取值:在Ajax调用中的一部分

下一篇: $ .ajax成功回调不在firefox中触发