javascript - Function call after Value is changed -


I am trying to get a logout button that first sets the session and then closes the actual tab gives.
So far I only got a part to destroy the session and I did not know how to close the tab. After the session ended with the session, I tried to resonate that function, but with the set interlol I did not manage to complete it. Does anyone know a few things? Thanks! Edit: All the codes are on the same page

Here's my code:

[HTML]

  & lt; Input type = "hidden" name = "vLogout" value = "wrong" & gt; & Lt; Input type = "button" value = "logout" name = "logging out" onClick = "logout (this.form)" style = "background-color: # cc0000; color: #ffffff" & gt;   

[PHP]
This is the first line of code & lt ;? Php

  if ($ _REQUEST ["vLogout"]) {session_start (); Session_unset (); Session_destroy (); Echo "& lt; script & gt; closeTab (); "; } [Javascript]  
  function logout (f) {var confirmation = confirmation ("Are you sure you want to log out?"); If (confirmation) {f.method = "post"; F.vLogout.value = true; F.submit (); }} Function closeTab () {confirm ("test"); //window.open(document.URL,'_self','resizable=no,top=-245,width=250,height=250,scrollbars=no '); //window.close (); }   

Note: Most probably, you have a tab with JS for security problems Can not stop You can just close a tab with JS opened with JS.

You can use JQuery to send an AJAX request to the server with no send form onclick event. When the dataset of the Ajax request is 'script', the browser will execute the reaction body in the form of JS

Note: Save the files in the same directory (index.php and logout.php).

In Index.html:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Ajax logout & lt; / Title & gt; & Lt; Style & gt; .blog-button {background: # 00aaee; Display: inline-block; Padding: 5px 10px; Cursor: indicator; } & Lt; / Style & gt; & Lt; Script type = "text / javascript" src = "http://code.jquery.com/jquery-1.10.2.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div class = "logout-button" & gt; Logout & lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Function closeTab () {confirm ("test"); // your code here} $ ('logout-button'). ('Click', function () {$ .ajax ({url: ('logout.fp'), type: 'post', data type: 'script'});}); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

In logout.php:

     

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -