Tuesday, 15 April 2014

Disappearing logout button with html, jquery, and php -



Disappearing logout button with html, jquery, and php -

i'm greenish programmer , can't find reply anywhere on web problem. help send way! i'm trying create basic login page users allows upload , allows user logout. during login, start session. works. both upload , logout, i'm using jquery.form.js library take advantage of form functionality. upload portion of code, works fine. user can upload images of type, button deactivated during upload, reactivated after success new uploads. however, logout portion, after clicking logout button , destroying session, logout button disappears. thought may have session destroy, without in php, button gone. copied logout portion of code below, in order, html, js, , php. ideas? thanks!

<html> <head> <title>sample</title> <meta http-equiv= "content-type" content="text/html; charset=utf-8"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script type = "text/javascript" src = "js/jquery.form.js"></script> <script type = "text/javascript" src = "js/xmlrequest.js"></script> <script>xmlrequest = new xmlrequest();</script> <script type = "text/javascript" src = "js/fileupload.js"></script> <script>fileupload = new fileupload();</script> </head> <body> <div id = 'userlogout'> <form action="php/logout.php" id = "logoutsection" enctype = "multipart/form-data" method = "post" > <button type="submit" id="logoutbutton">close!</button> </form> </div> <div id = 'logoutoutput'> </div> </body> </html> function fileupload() { $(document).ready(function() { $('#logoutsection').on('submit',function(a){ //prevent default action of going new page. a.preventdefault(); $('#logoutbutton').attr('disabled',''); $(this).ajaxsubmit({ target: '#userlogout', success: afterlogout//output give thanks message }); $('#loginform').show(); $('#logoutoutput').append("<br>thanks checking out!<br>"); }); }); function afterlogout() { $('#logoutsection').resetform(); $('#logoutbutton').removeattr('disabled'); } } <?php echo "<br>goner<br>"; session_start();//always required sessions session_destroy();//logs out ?>

i believe although i'm not sure reason why button gone after login out because using ajaxsubmit alternative target set #userlogout points parent div of form.

after ajaxsubmit success replace content of <div id='userlogout'> ... </div> result of of ajax operation.

i way: <div id='output'></div> <div id = 'userlogout'> <form action="php/logout.php" id = "logoutsection" enctype = "multipart/form-data" method = "post" > <button type="submit" id="logoutbutton">close!</button> </form> </div>

and alter ajaxsubmit target target: 'output'

read http://www.justwebdevelopment.com/blog/ajaxform-and-ajaxsubmit-options/ target identifies element(s) in page updated server response. value may specified jquery selection string, jquery object, or dom element. default value: null

php jquery logout

No comments:

Post a Comment