Jump to content


Photo

PHPP cookie help


  • Please log in to reply
8 replies to this topic

#1 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 25 April 2006 - 02:33 PM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 April 2006 - 05:10 PM

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]

#3 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 25 April 2006 - 10:13 PM

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


#4 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 27 April 2006 - 04:52 AM

Any suggestions?

#5 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 April 2006 - 02:46 PM

Bump.

#6 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 29 April 2006 - 04:50 PM

Any suggestions?

#7 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 01 May 2006 - 04:53 AM

Anyone got any ideas on what to put in the PHP files?

#8 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 02 May 2006 - 11:58 PM

Sorry for the bumps. :(

#9 neoaddict

neoaddict
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 05 May 2006 - 02:29 AM

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users