简体   繁体   中英

$.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM