admin管理员组文章数量:1130349
I have used wp_localize_script() to pass a variable to a javascript file.
var countries = [searchresults.data];
The variable is getting passed but I want it in a js file like below:
var countries = [item1,item2,item3];
The variable is correct searchresults.data = item1,item2,item3, but the countries variable has to be like var countries = [item1,item2,item3];
iIam not able to do. Please help
This is the $data that I passed
$data = array(
'data' => $searchresult,
);
wp_localize_script( 'searchautocompleter', 'searchresults', $data );
I have used wp_localize_script() to pass a variable to a javascript file.
var countries = [searchresults.data];
The variable is getting passed but I want it in a js file like below:
var countries = [item1,item2,item3];
The variable is correct searchresults.data = item1,item2,item3, but the countries variable has to be like var countries = [item1,item2,item3];
iIam not able to do. Please help
This is the $data that I passed
$data = array(
'data' => $searchresult,
);
wp_localize_script( 'searchautocompleter', 'searchresults', $data );
本文标签: theme developmentHow to echo inside the js file with wplocalizescript
版权声明:本文标题:theme development - How to echo inside the js file with wp_localize_script? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749113382a2317779.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论