我有点击链接后在躲在广告箱这个jQuery代码:阿贾克斯两次点击
$('a.close').click(function() {
var parent = $(this).parent().parent();
var adid = $(parent).attr('id');
$.ajax({
type: "POST",
url: "./setcookie.php",
data: "adid=" + adid,
cache: false,
dataType: 'json',
success: function (cook) {
if (cook.set === 'success') {
parent.fadeOut(1000);
}
},
error: function() {
$(".guestwarn").html("<font color='red'>There was an error submitting the form. Please try again.</font>").fadeIn(1000);
}
});
return false;
});
所以我想通过cookie关闭框。 我的HTML(PHP)是:
<?php if(isset($_COOKIE[ "msg1"])){?>
<div id="msg1" class="msgbox">
<div class="guestwarn">
<a href="#" class="close">X</a>
Something goes here...
</div>
</div>
<?php } ?>
所以我的工作setcookie.php是:
$adcookies = array();
$value = $_POST['adid'];
if ($value) {
setcookie($value, $value, time() + 3600);
if (isset($_COOKIE[$value])) {
$adcookies['set'] = "success";
} else {
$adcookies['set'] = "error";
}
echo json_encode($adcookies);
}
为什么adbox(.msgbox)两次点击后隐藏? 代码有什么问题? 谢谢
请花时间缩进您的代码。没有人想要解开这个混乱来理解你的问题。 – meagar 2013-03-11 20:03:15
@Wirey您已经介绍了格式错误。你真的不应该用这种方式编辑别人的代码。 – meagar 2013-03-11 20:04:20
tryed.Sorry for my English。 – 2013-03-11 20:09:48