Jump to content

PHPP cookie help


neoaddict

Recommended Posts

[code]<script type="text/javascript">
    function makeRequest(url) {
        var http_request = false;
        if (window.XMLHttpRequest) {
            http_request = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        if (!http_request) {
            alert('Your browser does not support AJAX or XMLHttpRequest!');
            return false;
        }
        http_request.open('GET', url, true);
        if (url == "checkcookie.php") {
            http_request.onreadystatechange = parse;
        }
        http_request.send(null);
    }

    function parse() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var css = http_request.responseText;
                document.getElementById("topsites").style.display = css;
            }
            else{
                alert('There was a problem with the request.');
            }
        }
    }

    open('checkcookie.php');

    function omgmagic() {
        if(document.getElementById("topsites").style.display == 'none'){
           makeRequest('show.php');
           document.getElementById("topsites").style.display = '';
        }
        else{
           makeRequest('hide.php');
           document.getElementById("topsites").style.display = 'none';
        }
    }
</script>

<div style="cursor: pointer;" onclick="omgmagic()">Expand/Collapse Topsites Images[/code]
That's my current code so far - I think I've got all the AJAX right, but I don't know what to put in the PHP files except setcookie, perhaps?

Thanks.
Link to comment
Share on other sites

What! Whats your question? Not a lot of info is comming from what you have said so fair!
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]That's my current code so far - I think I've got all the AJAX right, but I don't know what to put in the PHP files except setcookie, perhaps?

Thanks.[/quote]
Link to comment
Share on other sites

Well, I'm trying to make this AJAX script keep persistence for a collapse div script, I think I've got the AJAX all done, but I can't seem to figure out what to put in the PHP files.

checkcookie.php should check if cookies exists, and if so, outputs the value of the cookie to the AJAX script.
hide.php is for the hide cookie
show.php is for the show cookie
Link to comment
Share on other sites

Does anyone know what I can put in the PHP files?

I'm having problems figuring out what to put in them.

checkcookie.php should check for the cookie, if exists, display div accordingly and set output to script, if not, send do nothing output to script.

Don't know how to send output from a PHP file to an AJAX script.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.