呼应出许多文字。(通过调用等方式较少回显文本)好的,但是子脚本中的javascript正在调用parent.reloadprofmessages()。因此,基本上,您要调用php,它返回1或0,并将其存储到can_reload中。如果can_reload为

呼应出许多文字。(通过调用等方式较少回显文本)好的,但是子脚本中的javascript正在调用parent.reloadprofmessages()。因此,基本上,您要调用php,它返回1或0,并将其存储到can_reload中。如果can_reload为,php,javascript,jquery,function,parent,Php,Javascript,Jquery,Function,Parent,呼应出许多文字。(通过调用等方式较少回显文本)好的,但是子脚本中的javascript正在调用parent.reloadprofmessages()。因此,基本上,您要调用php,它返回1或0,并将其存储到can_reload中。如果can_reload为1,则调用parent.reloadprofmessages()。。。。哦,请注意,我在上面的答案中拼写的函数不正确。经过反复研究和阅读,我发现了我所尝试的函数的错误,我使用了您的示例,但决定使用$ajax.get()。我将在下面详细解释。(回


呼应出许多文字。(通过调用等方式较少回显文本)好的,但是子脚本中的javascript正在调用parent.reloadprofmessages()。因此,基本上,您要调用php,它返回1或0,并将其存储到can_reload中。如果can_reload为1,则调用parent.reloadprofmessages()。。。。哦,请注意,我在上面的答案中拼写的函数不正确。经过反复研究和阅读,我发现了我所尝试的函数的错误,我使用了您的示例,但决定使用$ajax.get()。我将在下面详细解释。(回答我的问题)
echo "<script>parent.reloadprofmessages();</script>"; //this is what is not getting called
function checkactivity($username)
{
    //These are just queries being executed (irrelevant)

    $querystats = "SELECT users.fullname, activity.id, activity.sender, activity.receiver, activity.type, activity.dateposted, activity.seen, activity.related FROM activity, users WHERE activity.receiver = '$username' && activity.seen = '0' ORDER BY id DESC LIMIT 1";
    $resultstats = mysql_query($querystats);
    $num_stats = mysql_num_rows($resultstats);
    $rowactivity = mysql_fetch_assoc($resultstats);

    //End of queries

    if($num_stats > 0) //If there are registries
    {
        $user = $_SESSION['Username'];

        $activity_date = $rowactivity["dateposted"];
        $activity_type = $rowactivity["type"];
        $activity_sender = $rowactivity["sender"];
        $timeactivity = strtotime( "$activity_date" );
        $actualtime = time();

        $timetoseconds = $actualtime - $timeposted; 
        $timetominutes = floor($timepassedtoseconds/60);

        if($timetominutes < 2)
        {
            if($activity_sender != $user)
            {
                if($activity_type == 1) //Messages
                {
                    echo "<script>parent.reloadprofmessages();</script>"; //this is what is not getting called
                }
            }
        }

    }
}
function reloadprofmessages()
{
    $('#friendrequests').load('showprofmessages.php?username=<?php echo $actualuser; ?>').fadeIn("slow");
} //refreshes messages
if($activity_type == 1) //Messages
{
    echo "1";
}
else {
    echo "0";
}
function reloadprofmessages()
{
    var can_reload = $.ajax({ url: "showprofmessages.php?username=<?php echo $actualuser; ?>" });
    if (can_reload) {
        parent.erloadprofmessages();
    }
}
echo "<script type='text/javascript' >parent.reloadprofmessages();</script>"; 
function checkactivity($username)
{
    //These are just queries being executed (irrelevant)

    $querystats = "SELECT users.fullname, activity.id, activity.sender, activity.receiver, activity.type, activity.dateposted, activity.seen, activity.related FROM activity, users WHERE activity.receiver = '$username' && activity.seen = '0' ORDER BY id DESC LIMIT 1";
    $resultstats = mysql_query($querystats);
    $num_stats = mysql_num_rows($resultstats);
    $rowactivity = mysql_fetch_assoc($resultstats);

    //End of queries

    if($num_stats > 0) //If there are registries
    {
        $user = $_SESSION['Username'];

        $activity_date = $rowactivity["dateposted"];
        $activity_type = $rowactivity["type"];
        $activity_sender = $rowactivity["sender"];
        $timeactivity = strtotime( "$activity_date" ); //$timeactivity was not being used
        $actualtime = time();

        $timetoseconds = $actualtime - $timeposted; //$timeposted doesn't even exist, in other words I wasn't even converting the $activity_date timestamp to time.
        $timetominutes = floor($timepassedtoseconds/60);

        if($timetominutes < 2)
        {
            if($activity_sender != $user)
            {
                if($activity_type == 1) //Messages
                {
                    echo "<script>parent.reloadprofmessages();</script>"; //this was not the correct way of calling a function from the parent page.
                }
            }
        }

    }
}
var auto_refresh = setInterval(
function reloadstring()
{
        $.get("checknewactivity.php?vprofile=<?php echo $actualuser; ?>", function(activity){
        if (activity == 1) 
        {
            $('#profcommentsdiv').load('showprofmessages.php?vprofile=<?php echo $actualuser; ?>').fadeIn("slow");
        }
        });
}, 1000); // refresh every 1000 milliseconds