我有一个页面,列出了许多视频的名称和其他详细信息。已登录的用户可以单击此视频的名称,将特定视频添加到他/她的投资组合中。请注意,登录的人和没有登录的人都可以看到这个视频列表。所以我有代码执行以下操作 -
a)单击视频时,功能会检查此人是否已登录。如果没有,则会闪烁错误消息。否则,代码继续调用第二个函数。
b)在第二个功能中,会出现一个框,要求用户输入验证密码(这些是付费视频,因此需要进行双重检查)。这就是问题所在。用户可以决定不继续输入密码,只需关闭新框即可。他可能输入了错误的密码,或者他的帐户可能因输入错误密码超过一定次数而被计时。
我面临的问题是,如果用户关闭密码框,然后单击其他视频,再次关闭密码框而不输入密码,然后单击另一个视频并正确输入密码。发生的事情是这三个视频都被添加到该用户组合中。我希望我的问题清楚了。我想要实现的是,在关闭密码框时,应该退出整个函数链。这没有发生,关闭框后,功能只是悬挂而不退出。请帮助。
以下是我的代码 - 1)点击视频名称的代码
$(document).on("click", "[id^='Concept']", function (e) {
e.preventDefault();
var x = $(this).attr('id').substring(7);
checklogin(x);
});
2)功能检查登录
function checklogin(id){
$.ajax({
url: "mysession.php",
dataType: "json",
success: function(response){
console.log(response);
if(response.userid === ""){
alert("Please login/register to create you portofilio of tutorial videos");
}else{
checkpass(id);
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert(jqXHR.status+", " + jqXHR.statusText+", "+textStatus+", "+errorThrown);
}
});
}
3)功能检查通道
function checkpass(id){
$("#pwdErrMsg").html("Please enter your Tutorial Password");
$("#Transaction").css("display","block");
var tutexit = false;
$(".close").click(function(){
$("#pwdErrMsg").html("Please enter your Tutorial Password");
$("#transpwd").val("");
$("#Transaction").css("display","none");
tutexit = true;
return false;
});
if(tutexit)
{
return false;
}
$("#callpwd").click(function(e){
e.preventDefault();
var serializedData = $("#pwdform").serialize();
$.ajax({
url: "Tutelogin.php",
type: "POST",
async: true,
data: serializedData,
success: function(response){
if(response.indexOf("invalid")>0){
$("#pwdErrMsg").html(response);
$("#transpwd").val("");
}else if (response.indexOf("missing")>0){
$("#pwdErrMsg").html(response);
}else if (response.indexOf("locked")>0){
$("#pwdErrMsg").html(response);
$("#Transaction").css("display","none");
tutexit = true;
return false;
}else if (response.indexOf("Success")>0) {
addtutorial(id);
$("#Transaction").css("display","none");
tutexit = true;
return false;
}
},
error : function (ts) {
alert(ts.responseStatus);
}
});
});
if(tutexit)
{
return false;
}
}
函数addtutorial最后将视频添加到投资组合中。我没有提供这个功能,因为这不是问题。