【发布时间】:2018-12-24 10:13:32
【问题描述】:
我在 post 函数中调用了一个变量 (t_d_url)。它不显示可变数据。它只显示变量名。
我试过这样称呼它:
$.post(t_d_url.'/ascott/includes/booking/booking-summary.php', {}, function(data) {
$(".booking-summary").html(data);
});
这里是变量:
var t_d_url = '<?php echo get_template_directory_uri(); ?>';
这是输出:
所以我想在这个函数中显示这个变量数据。
【问题讨论】:
-
为什么不直接做
$.post('<?php echo get_template_directory_uri(); ?>'+'/ascott/includes/booking/booking-summary.php',... -
后面看代码比较复杂..
-
如果使用js可以不用'+'号代替'.'运算符
-
是的...他正在使用 PHP 语法
-
你应该学会在 WP 中正确使用 AJAX。只是为了确保您保持一切安全并正常工作。 codex.wordpress.org/AJAX_in_Plugins
标签: javascript php ajax wordpress