I am trying to use jQuery with PHP, like this:
<th bgcolor="#FFCC00" align="center">
<a href="" title="Sort" name="fname" id="fname" >First Name</a>
<?php if($_REQUEST['o']=="fn"){ ?><img border="0" id="b1" /><?php } ?>
</th>
jQuery code:
$('#fname').click(function() {
alert ("come");
<?php if ($_REQUEST['o'] == "fn") { $_SESSION['clicked'] = "fn"; } ?>
window.location = '<?php echo $redirect ?>Clients.php?o=fn';
return false;
But it doesn’t work. Thank you for any help.
You can’t use PHP inside of JavaScript, not the way you are trying to.
All PHP code is evaluated server-side – while the page is being generated.
Not while jQuery is processing some callback.
This line will not work:
If you clarify what you want your AJAX to do, we can help you make it do that.