Hobbyist_PHPer Posted May 17, 2012 Share Posted May 17, 2012 Hi, I have a jQuery function that loads a page inside of a DIV, that page shows an availability status button, only when that status is set to available, the status button becomes a link... here's that link... if ($row['AgentLoggedState'] == "available") { echo '<a href="javascript:void(0);" onclick="showElem(\'RedeemAuthorizationCode\');"><img src="http://xxxxxxxx.xxx/images/status_'.$row['AgentLoggedState'].'.png" alt="'.$row['AgentLoggedState'].'" /></a>'; } else { echo '<img src="http://xxxxxxxx.xxx/images/status_'.$row['AgentLoggedState'].'.png" alt="'.$row['AgentLoggedState'].'" />'; } Then on the main page, I have these 2 jQuery functions... <? session_start(); include '../../connection.inc'; $query = "SELECT AgentLoggedState FROM Agents WHERE AgentID = '1'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result) ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <link href="http://xxxxxxx.xxx/StyleSheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> var showElem; showElem = function( showID ) { div = (( document.getElementById ) ? document.getElementById( showID ) : document.all[ showID ] ); try { div.className = (( div.className === "hide" ) ? "show" : "hide" ); } catch( e ) { div.style.display = (( div.style.display === "none" ) ? "block" : "none" ); } }; </script> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function() { $("#responsecontainer").load("../../response.php"); var refreshId = setInterval(function() { $("#responsecontainer").load('../../response.php'); }, 1000); $.ajaxSetup({ cache: false }); }); </script> </head> What I need to happen is, when this link, <a href="javascript:void(0);" onclick="showElem(\'RedeemAuthorizationCode\');">, is clicked, I need the main page to first reload, so that it can fire the PHP/MySQL query prior to showing the hidden DIV... Any suggestions would be greatly appreciated... Thank You Quote Link to comment https://forums.phpfreaks.com/topic/262685-reload-page-before-function-fires/ Share on other sites More sharing options...
haku Posted May 18, 2012 Share Posted May 18, 2012 If you reload the page, any running javascript processes are killed. They do not persist between page loads. So you can't really do what you want. If you want something from PHP/MySQL after page load, you will need to use an ajax implementation to do so. Quote Link to comment https://forums.phpfreaks.com/topic/262685-reload-page-before-function-fires/#findComment-1346515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.