html - jquery form submission not working -


i'm using jquery-1.10.1 , html code is:

<li>   <a href='' id='logout'>log out</a></li>     <form id='logout_form' method='post'>      <input type='hidden' name='logout' value='true' />     </form> 

my jquery code @ end of every document:

<script type="text/javascript"> $(function() {     $("#logout").click(function(){         $("#logout_form").submit();     }); }); </script> 

and php code this:

if(!empty($_post['logout'])){     $object=new logout();     $content='5;url='.$path.'index.php'; } 

but form submission not working. pls me.

the problem href=' ' attribute, remove it

change this:

<a href='' id='logout'>log out</a> 

for this:

<a id='logout'>log out</a> 

you can add css avoid lost pointer cursor

<style>    a{cursor:pointer} </style> 

you can , should change anchor div or span , add css

update: code used:

<html>     <head>         <meta http-equiv="content-type" content="text/html; charset=iso-8859-9">         <title></title>         <script src="js/jquery.min.js"></script>         <script>             $(function() {                 $("#logout").click(function(){                     $("#logout_form").submit();                 });             });          </script>         <?php         if (!empty($_post['logout'])) {             echo 'hola.<br>';         }else{             echo 'wrong.<br>';         }          ?>     </head>     <a  id='logout'>log out</a></li> <form id='logout_form' method='post'>     <input type='hidden' name='logout' value='true' /> </form> </body> </html> 

outpout after click on log out:

hola  log out 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -