【发布时间】:2015-01-19 10:25:48
【问题描述】:
我正在尝试从我的 .js WordPress 主题文件中的数据库中获取少量数据。 我尝试使用 jquery 的 .post() ,但没有任何反应。
还请给我建议任何替代方案。
.js 文件中的代码
jq.post("../abc.php",
{
name:"kumar",
accId:window.accommodationId
}, function(data,status)
{
alert("hello");
//alert("Data: " + data + "\nStatus: " + status);
}
);
abc.php 文件中的代码
<?php
global $wpdb;
$max_minAge = $wpdb->get_results( "SELECT price_per_day FROM wp_byt_accommodation_vacancies where accommodation_id='1741'" );
echo $max_minAge[0]->price_per_day;
?>
【问题讨论】:
-
它叫做
AJAX异步javascript和xml。 -
对 wp codex.wordpress.org/Plugin_API/Action_Reference/…中的所有类型的 ajax 请求使用 wp_ajax 钩子
-
请说明我必须在我的 .php 文件中添加任何特殊代码或什么。