Sunday, 15 January 2012

javascript - changing session variable not working -



javascript - changing session variable not working -

<?php session_start(); include 'cardclass.php'; $cards = new deck(); $cards = unserialize($_session['cards']); $cards->drawcard(); $cards->pushback(); $_session['cards'] = serialize($cards); exit(); ?>

i have php page creates deck shuffles stores in session. have code gets session object draws card , puts card of deck save session. when phone call 4 times "4 hearts 4 hearts 4 hearts 4 hearts" instead of 4 different cards. believe because not saving session correctly.

edit:

function dealcard(){ var xmlhttp = new xmlhttprequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("computer").innerhtml+=xmlhttp.responsetext; } } xmlhttp.open("get","dealcard.php",true); xmlhttp.send(); }

i have feeling has it

function dealcard(){ var xmlhttp = new xmlhttprequest(); xmlhttp.open("get","dealcard.php",false); xmlhttp.send(); document.getelementbyid("computer").innerhtml+=xmlhttp.responsetext; }

changed js function , works now. async messing it.

javascript php ajax session

No comments:

Post a Comment