Javascript 将隐藏表单字段发送到Wordpress站点上的服务器
我刚开始使用Wordpress,我正在使用一个名为textcomplete with Algolia search的Javascript 将隐藏表单字段发送到Wordpress站点上的服务器,javascript,php,jquery,wordpress,forms,Javascript,Php,Jquery,Wordpress,Forms,我刚开始使用Wordpress,我正在使用一个名为textcomplete with Algolia search的JQuery插件,允许用户在我网站的评论部分@提及其他用户,如下面的代码所示 $input.textcomplete([ { match: /\B@(\w*)$/, search: function(term, callback) { lastQuery = term; myIndex
JQuery
插件,允许用户在我网站的评论部分@提及其他用户,如下面的代码所示
$input.textcomplete([
{
match: /\B@(\w*)$/,
search: function(term, callback) {
lastQuery = term;
myIndex.search(term, { hitsPerPage: 5 }, function(err, content) {
if (err) {
throw err;
}
if (content.query === lastQuery) {
callback(content.hits);
}
});
},
template: function (hit) {
console.log(hit);
return hit._highlightResult.display_name.value;
},
replace: function (hit) {
return ' @' + hit.display_name + ' ';
},
index: 1
}
]);
我想将hit.display\u name变量发送到服务器,作为MySQL
查询的一部分使用。通常情况下,我会将其设置为一个隐藏的表单字段,并将其发布到需要的php文件中(在本例中为wp comments post.php),但使用Wordpress处理注释表单的方式(使用comment_form函数并向其传递一个关联的对象数组),我不确定如何做到这一点。。。
所以我的问题是如何访问wp-comments-post.php文件中的hit.display_name变量