0

I'm using easyModal to create modal windows in my web. Saw that they have callback onClose and I want use php code on close is it possible, if yes How to do that? I want to unset some values from sessions (don't have much experience in javascript, jquery or ajax)

This is my code:

<div id="ebox">
    <?php
    echo $_SESSION['unameE'];
    echo $_SESSION['pwordE'];
    echo $_SESSION['emailE'];
    ?>
</div>

$(function() {
    $('#ebox').easyModal( {
        autoOpen:<?php echo $error; ?>
        onClose:???

    });
});

Or maybe there is another solution that unsets values from session after displaying it once?

3
  • as long as the js is in line within the php page then you should be able to but its not nice. Why don't you load a php page into the modal and do the code within that, but within as a function not recommended ect Commented Dec 30, 2013 at 22:21
  • 1
    $.ajax({ url: 'script.php?argument=value&foo=bar' }); see: stackoverflow.com/questions/3548802/… Commented Dec 30, 2013 at 22:39
  • look into AJAX/jQuery's $.post function. you can't straight-up mix JS and PHP, they are separate processes on the client and server-side, respectively. Commented Dec 30, 2013 at 23:18

1 Answer 1

0

on your script you should have :

onClose: function(){ 
   $("#ebox").html(' ') ; 
   $.post("remove-session.php"); 
}

and then on the page "remove-session.php" you can do all sort of stuff with your session:

<?php 
  unset($_SESSION['unameE']); 
  //... 
  //or even
  session_destroy(); 
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.