我在php页面中显示了一行。每行都有一个单独的“喜欢”按钮。 要喜欢任何行,用户应首先登录。 现在,如果任何用户点击任何类似按钮,&如果用户未登录,那么我将在灯箱中显示他们的登录表单。
我想要的是:
如果登录验证成功,那么我想继续ajax之类的操作,用户点击该特定行,即它应该是用户想要的先前操作,例如http://localhost/coments/like/193
怎么做,请帮我解决这个问题。
我使用了以下技术,但它没有调用之前的操作,尽管它在同一页面中转发它。
...............
...............
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
}
答案 0 :(得分:0)
您可以将操作存储在数组中,例如:
var actions = [] ;
actions.push(function(){
//Hide something, make something appear
}) ;
//or just
var lastAction = function(){
//Do your stuff
} ;
修改强>
var actionsOnLogin = [] ; //Create array of executable functions
想象一下,如果有人投票:发送ajax请求。
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
}
}
然后用户再次使用AJAX登录:
success: function(dat){
if(dat.status == 'success'){
for(var key in actionsOnLogin){
actionsOnLogin[key](); //Execute every function in that array
}
}
}