【发布时间】:2011-05-05 09:59:00
【问题描述】:
我正在尝试在我的一个 jQuery 函数中使用我的一个 PHP 函数。我知道它不会执行代码,但我需要回显函数调用,以便服务器可以处理它。到目前为止,我有这个:
.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)')
但它无法正常工作。我听说我需要用引号将 Javascript 中的实际 php 函数调用括起来,我做了(单引号和双引号),但他们没有做到这一点。有什么想法吗?
任何想知道的人的整个功能:
// 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();
});
});
});
【问题讨论】:
-
你试过没有absolute_url函数的文本吗
标签: php javascript jquery echo