I'm trying to use one of my PHP functions within one of my jQuery functions. I understand that it won't execute the code, but I need to echo the function call, so the server can process it. So far I have this:
.html('<h2>Please <a href=""<?php echo absolute_url("login.php"); ?>"">login</a> or <a href="signup.php">register</a> to vote for this post.</h2>(click on this box to close)')
But it's not working correctly. I heard that I need to enclose the actual php function call within Javascript with quotation marks, which I did (both single and double), but they didn't do the trick. Any ideas?
The whole function for anyone wondering:
// login or register notification
$(document).ready(function() {
$('.notice').click(function() {
$('.error-notification').remove();
var $err = $('<div>').addClass('error-notification')
.html('<h2>Please <a href=""<?php echo absolute_url("login.php"); ?>"">login</a> or <a href="signup.php">register</a> to vote for this post.</h2>(click on this box to close)')
.css('left', $(this).position().left);
$(this).after($err);
$err.fadeIn(150);
});
$('.error-notification').live('click', function() {
$(this).fadeOut(150, function() {
$(this).remove();
});
});
});