Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php块中添加javascript变量作为参数?_Javascript_Php_Wordpress_Google Maps - Fatal编程技术网

如何在php块中添加javascript变量作为参数?

如何在php块中添加javascript变量作为参数?,javascript,php,wordpress,google-maps,Javascript,Php,Wordpress,Google Maps,我正在创建一个网站,它使用wordpress中的谷歌地图来显示多个标记,点击每个标记,就可以从数据库中检索相应的帖子。我正在尝试向标记添加一个侦听器,并希望它获得一个具有特定post id的自定义字段。我可以通过以下代码实现这一点,不使用post id的任何变量: for (i=0;i<map.markers.length;i++){ thepostid = map.markers[i].postID; marker.addListener('click',

我正在创建一个网站,它使用wordpress中的谷歌地图来显示多个标记,点击每个标记,就可以从数据库中检索相应的帖子。我正在尝试向标记添加一个侦听器,并希望它获得一个具有特定post id的自定义字段。我可以通过以下代码实现这一点,不使用post id的任何变量:

for (i=0;i<map.markers.length;i++){
        thepostid = map.markers[i].postID;
        marker.addListener('click', function() {
              $('#article-bottom p').text('<?php echo get_field('sound_description', 59);
        });
    }

用于(i=0;iIt看起来您没有在第一个代码块中关闭php块,在第二个示例中关闭它两次您必须使用AJAX。没有其他方法了。@SergeyVidusov Sergey,因为我对这个AJAX概念还不熟悉,您能给我一个提示,说明如何在我的示例中实现它吗?提前感谢您的帮助。
$('#article-bottom p').text('<?php echo get_field('sound_description',?>' + thepostid + '<?php );?>');