jquery - call to php file via ajax not working -
this seems relatively simple question, , pretty new using ajax, saw post being able call php script when onclick event has been triggered. trying destroy session upon user clicking "log out" link, want call logout.php file when onclick event has occurred. problem nothing happens when link clicked.
here's code:
$(document).ready(function() { // expand panel $("#open").click(function(){ //when user clicks logout button $.ajax({ url: "logout.php" )}; }); }); <div class="tab"> <ul class="login"> <li class="left"> </li> <li><?php if(isset($_session['username'])){echo $_session['username'];}else{echo 'hello guest!';}?></li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#">log out</a> </li> <li class="right"> </li> </ul> </div> <!-- / top -->
i suppose expect output of logout.php file show. think code might working forgot tell ajax put data receives.
try this:
$.ajax({ url: 'logout.php', success: function(data) { $('.result').html(data); alert('logout completed.'); } }); where "result" points div want load response into.
Comments
Post a Comment