0

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(); 
                        window.location.href = '<?php uri_string(); ?>'; 
                        //this is not calling the previous action, but correctly it is forwarding to the correct paage

                    }
4

1 回答 1

0

You could store your actions in array for instance:

var actions = [] ;
actions.push(function(){
  //Hide something, make something appear
}) ;

//or just

var lastAction = function(){
  //Do your stuff
} ;

Edit:

var actionsOnLogin = [] ; //Create array of executable functions

Imagine if someone votes up: sends ajax request.

success: function(dat){
  var func = function(){
    //Increment number by one,  change some graphics.
  }
  if(dat.status == 'success'){
    func() ; //Execute that function
  } else {
    actionsOnLogin.push(func); //Store that function in array
  }
}

Then user logs in using AJAX again:

success: function(dat){
  if(dat.status == 'success'){
    for(var key in actionsOnLogin){
      actionsOnLogin[key](); //Execute every function in that array
    }
  }
}
于 2013-05-11T12:22:48.840 回答