gpt4 book ai didi

JavaScript FF IE 更新 + 消息脚本问题

转载 作者:行者123 更新时间:2023-12-02 20:41:41 25 4
gpt4 key购买 nike

我有一个 ajax_update 脚本,每 60 秒更新一次 file.php 。现在 file.php 在更新表格后输出:

<div id='message' style="display: none;">
<span>Hey, <b><? echo $userid; ?></b>, You've got +1 points, you now have <u>
<? echo $n["points"]; ?></u></span>
<a href="#" class="close-notify" onclick="closeNotice()">X</a>
</div>
<script>
$("#message").fadeIn("slow");
</script>

为什么这只在 FF 中起作用,我的意思是出现,但在 IE 中不起作用..

我想做的是,在 file.php 更新数据库中的字段(点)后,顶部会出现一条类似 stackoverflow 的消息(就像您获得徽章时一样),表示您已经获得 1 分。

这在 FF 中完美运行,但在 IE 中,该消息根本不显示?

也许还有另一种方法可以做到这一点?或者修复、解决方案?

我尝试将小 JS 脚本放入 index.php 并删除 ajax 更新内容,它在 IE 中工作正常。

function addpoints()  { 
var userid = document.getElementById('user_id_points');
var postFile = 'addpoints.php?userid='+ userid.value;
$.post(postFile, function(data){
$("#message").fadeIn("slow");
$("#points").html(data);
setTimeout(addpoints, 62000);
});
}

function closeNotice() {
$("#message").fadeOut("slow");
}

我的ajax脚本^

<?php
include "tilslut.php";
$userid = $_GET["userid"];
$s = mysql_query("SELECT points, lastpoint FROM member_profile WHERE user_id = '".$userid."'");
$n = mysql_fetch_array($s);
$tid = time();
mysql_query("UPDATE member_profile set points = points+1, lastpoint=$tid WHERE lastpoint<=$tid-60 AND user_id = '".$userid."'");
if(isset($userid)) {
$e = mysql_query("SELECT points FROM member_profile WHERE user_id = '".$userid."'");
$f = mysql_fetch_array($e);
echo $n["points"];
}elseif (mysql_affected_rows() == 1) {
$s = mysql_query("SELECT points FROM member_profile WHERE user_id = '".$userid."'");
$n = mysql_fetch_array($s);
?>
If you receive this text, no problem with php
<div id="message" onclick="closeNotice()">this works
</div>
<?
}else{
?>
This doesnt work at all
<?
}
?>

我的 php 编码,带有

最佳答案

在您的 ajax 更新脚本中,在结果出现后调用此脚本:

$("#message").fadeIn("slow");

作为请求的一部分返回的脚本不可靠,在这种情况下,将逻辑放入 ajax 结果函数中是更好的方法。

在你的 ajax 调用中试试这个:

function addpoints()  { 
var postFile = 'addpoints.php?userid='+ $('#user_id_points').val();
$.post(postFile, function(data){
$("#points").html(data).find("#message").fadeIn("slow")
setTimeout(addpoints, 62000);
});
}

关于JavaScript FF IE 更新 + 消息脚本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2259657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com