Possible Duplicate:
Creating jQuery AJAX requests to a PHP function
How can i write PHP in Jquery
is there is a way to do this
$('button').click(function(){
<?php session_destroy();?>
}) ;
Possible Duplicate:
Creating jQuery AJAX requests to a PHP function
How can i write PHP in Jquery
is there is a way to do this
$('button').click(function(){
<?php session_destroy();?>
}) ;
You can't execute PHP client-side.
You can call a php script on click to do what you want:
$('button').click(function(){
$.get("destroySession.php");
});
You can also get
or post
some values:
var values = {
destroy: true
};
//get request:
$.get("destroySession.php", values);
//post request:
$.post("destroySession.php", values);
You can't execute PHP client-side.
You cannot. PHP is interpreted on the server side and jQuery is interpreted on the client side.
You should either use an anchor <a href="session_destroy.php">
to go to another PHP page and destroy the session or use AJAX to call the destroy function without leaving the page.
jQuery('button').click( function () { jQuery.get("session_destroy.php"); } );