Jump to content

Reload page before function fires


Hobbyist_PHPer

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/262685-reload-page-before-function-fires/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.