ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to continue the previous ajax action after login

May 11, 2013 9:07am

Subscribe [1]
  • #1 / May 11, 2013 9:07am

    ansuman

    2 posts

    I have a row displaying in a php page. Each row is having a seperate “like” button.
    To like any row user should login first.
    Now, if any user click on any like button, & if user is not logged In, then i am showing them login form in a lightbox.

    **What i want is:**
      If login authentication is successful, then i want to continue that ajax like action which user clicked to like that specific row i.e it should the previous action which users intended for eg.`http://localhost/coments/like/193`
    How to do this, please help me to solve this issue.

    i used the below technique, but its not calling the previous action though its forwarding it in same page.
     

    ...............
        ...............
         success: function(dat){
                            if(dat.status == 'success')
                            {   $('#fcboxlogindiverror').hide();  $('#facebox_login_progress').hide(); 
                                [removed].href = '<?php uri_string(); ?>'; 
                                //this is not calling the previous action, but correctly it is forwarding to the correct paage
                                     
                            }

    What exactly i am trying to implement:
    In stackoverflow, if user is not logged in and tries to vote-up, then a login form opens in a facebox, if my login is successful then the the vote increase


    Full jquery/ajax function

    [removed] 
            $(document).ready(function() {
                var _status = $('#fcboxlogindiverror'); 
                $('#sub1').click(function(e){ 
                    $('#facebox_login_progress').show();
                    $('#sub1').attr('disabled',true);
                    $('#facebox_signupErrorDiv').hide();  
                    e.preventDefault();
                    _status.html(''); 
                    $.ajax({
                        url:"<?php echo base_url('ajax__facebox_login_regis/index'); ?>",
                        type:"post",
                        data: $('#form-one').serialize(),
                        dataType: "json",
                        success: function(dat){
                            if(dat.status == 'success')
                            {   $('#fcboxlogindiverror').hide();  $('#facebox_login_progress').hide(); 
                                [removed].href = '<?php uri_string(); ?>';  //this is not calling the previous action, but correctly it is forwarding to the correct paage
                                     
                            } 
                            else if(dat.status == 'password_changed'){[removed].href = '<?php echo base_url('login'); ?>';   }     
                            else if(dat.status == 'many_attempt'){[removed].href = '<?php echo base_url('login/lostpassword'); ?>';   }  
                            else
                            {   $("#fcboxlogindiverror").empty();
                                $('#facebox_login_progress').hide(); 
                                $('#sub1').attr('disabled',false);
                                          
                                         
                                $('.error').css('border' , '1px solid #dd3c10');
                                $('.error').css('padding' , '0.1em 0.1em 0.1em 36px');
                                          
                                _status.html('<span class="err">'+dat.message+'</span>');
                                $("#fcboxlogindiverror").fadeIn("slow");
                                             
                                $("#fcboxlogindiverror").click(function() {
                                    $("#fcboxlogindiverror").fadeOut("slow");
                                    return false;
                                });
                            }
                        },
                        error: function(err){$('#facebox_login_progress').hide();
                            alert("Something!-" + err);
                        }
                    });
                });
                 
            });      
        [removed]
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases