PHP + Javascript parent function not getting called -



PHP + Javascript parent function not getting called -

alright i've been trying find reply hours couldn't resolve myself. i'm trying phone call javascript parent function php function, however, not getting called. when using onclick method onclick='parent.dosomething(); seems work fine if seek phone call function echo'ing out, fail reason.

echo "<script>parent.reloadprofmessages();</script>"; //this not getting called

here's php function:

function checkactivity($username) { //these queries beingness executed (irrelevant) $querystats = "select users.fullname, activity.id, activity.sender, activity.receiver, activity.type, activity.dateposted, activity.seen, activity.related activity, users activity.receiver = '$username' && activity.seen = '0' order 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 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 not getting called } } } } }

and javascript function @ parent page:

function reloadprofmessages() { $('#friendrequests').load('showprofmessages.php?username=<?php echo $actualuser; ?>').fadein("slow"); } //refreshes messages

i pressed ctrl + shift + in google chrome developer tools, network > page request calls php function > preview , received: <script>parent.reloadprofmessages();</script> however, function not getting called. resolving solve me lot of problems, me still mystery know why doesn't work since has worked in other cases. give thanks help in advance.

it's not thought fetch javascript , execute ajax. suggest firstly alter php this:

if($activity_type == 1) //messages { echo "1"; } else { echo "0"; }

then alter javascript this:

function reloadprofmessages() { var can_reload = $.ajax({ url: "showprofmessages.php?username=<?php echo $actualuser; ?>" }); if (can_reload) { parent.erloadprofmessages(); } }

hope helps

php javascript jquery function parent

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -