Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
在JQuery中调用/获取php变量值_Php_Jquery_Json_Audio_Jplayer - Fatal编程技术网

在JQuery中调用/获取php变量值

在JQuery中调用/获取php变量值,php,jquery,json,audio,jplayer,Php,Jquery,Json,Audio,Jplayer,我目前正在学习jplayer的工作原理。我遇到了这个代码 <script type="text/javascript"> $(document).ready(function(){ $("#jquery_jplayer_1").jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4a:

我目前正在学习jplayer的工作原理。我遇到了这个代码

    <script type="text/javascript">
        $(document).ready(function(){
          $("#jquery_jplayer_1").jPlayer({
            ready: function () {
              $(this).jPlayer("setMedia", {
                m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
                oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
              });
            },
            swfPath: "js",
            supplied: "m4a, oga"
          });
        });
  </script>
m4a:
中,我想调用/插入php代码的值,比如$file\u path。 我该怎么做?因为我将从数据库中获取文件路径,并将其存储在php变量中

  m4a: "<?php echo $file_path ?>",
m4a:”,
如果启用了短标记,则其可读性会更高

    <script type="text/javascript">
    $(document).ready(function(){
     var $filepath = "<?=$file_path?>"; //javascript variable can be start with $
      $("#jquery_jplayer_1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            m4a: $filepath+"/filename.mp4",
            oga: $filepath+"/filename.oga",
          });
        },
        swfPath: "js",
        supplied: "m4a, oga"
      });
    });
  </script>

$(文档).ready(函数(){
var$filepath=”“;//javascript变量可以以$
$(“#jquery_jplayer_1”).jplayer({
就绪:函数(){
$(this).jPlayer(“setMedia”{
m4a:$filepath+“/filename.mp4”,
oga:$filepath+“/filename.oga”,
});
},
swfPath:“js”,
供应:“m4a,oga”
});
});
试试这个

  m4a: "<?php echo $file_path ?>",
m4a:”,
如果启用了短标记,则其可读性会更高

    <script type="text/javascript">
    $(document).ready(function(){
     var $filepath = "<?=$file_path?>"; //javascript variable can be start with $
      $("#jquery_jplayer_1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            m4a: $filepath+"/filename.mp4",
            oga: $filepath+"/filename.oga",
          });
        },
        swfPath: "js",
        supplied: "m4a, oga"
      });
    });
  </script>

$(文档).ready(函数(){
var$filepath=”“;//javascript变量可以以$
$(“#jquery_jplayer_1”).jplayer({
就绪:函数(){
$(this).jPlayer(“setMedia”{
m4a:$filepath+“/filename.mp4”,
oga:$filepath+“/filename.oga”,
});
},
swfPath:“js”,
供应:“m4a,oga”
});
});

您只需在JavaScript中对其进行
回显即可,如下所示:

<script type="text/javascript">
        $(document).ready(function(){
          $("#jquery_jplayer_1").jPlayer({
            ready: function () {
              $(this).jPlayer("setMedia", {
                m4a: "<?php echo $file_path_m4a; ?>",
                oga: "<?php echo $file_path_oga; ?>"
              });
            },
            swfPath: "js",
            supplied: "m4a, oga"
          });
        });
  </script>

$(文档).ready(函数(){
$(“#jquery_jplayer_1”).jplayer({
就绪:函数(){
$(this).jPlayer(“setMedia”{
m4a:“,
oga:“
});
},
swfPath:“js”,
供应:“m4a,oga”
});
});

您只需在JavaScript中对其进行
回显即可,如下所示:

<script type="text/javascript">
        $(document).ready(function(){
          $("#jquery_jplayer_1").jPlayer({
            ready: function () {
              $(this).jPlayer("setMedia", {
                m4a: "<?php echo $file_path_m4a; ?>",
                oga: "<?php echo $file_path_oga; ?>"
              });
            },
            swfPath: "js",
            supplied: "m4a, oga"
          });
        });
  </script>

$(文档).ready(函数(){
$(“#jquery_jplayer_1”).jplayer({
就绪:函数(){
$(this).jPlayer(“setMedia”{
m4a:“,
oga:“
});
},
swfPath:“js”,
供应:“m4a,oga”
});
});

许多人都说只需将这些值呼出即可。重要的是,只要您使用的文件是由PHP解释的,那么无论文件扩展名是什么,您都可以做任何事情。如果文件以.php结尾,您的服务器可能已经这样做了,但您也可以将.js或.html文件添加到php解释器中。

许多人说只需将值回显即可。重要的是,只要您使用的文件是由PHP解释的,那么无论文件扩展名是什么,您都可以做任何事情。如果文件以.php结尾,您的服务器可能已经这样做了,但您也可以向php解释器添加.js或.html文件。


<script type="text/javascript">
    $(document).ready(function(){
      $("#jquery_jplayer_1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            m4a: "<?php echo FILE_PATH.filename_mp4;?>",
            oga: "<?php echo FILE_PATH.filename_ogg;?>"
          });
        },
        swfPath: "js",
        supplied: "m4a, oga"
      });
    });
$(文档).ready(函数(){ $(“#jquery_jplayer_1”).jplayer({ 就绪:函数(){ $(this).jPlayer(“setMedia”{ m4a:“, oga:“ }); }, swfPath:“js”, 供应:“m4a,oga” }); });


$(文档).ready(函数(){
$(“#jquery_jplayer_1”).jplayer({
就绪:函数(){
$(this).jPlayer(“setMedia”{
m4a:“,
oga:“
});
},
swfPath:“js”,
供应:“m4a,oga”
});
});

对于单个php行不是必需的,如何。更改构造函数?如果文件不是m4a,则与之类似。它不会使用m4a。它会用mp3吗?@diEcho我习惯于放一个
所以我总是把它放在我的代码中。它不会影响输出,是吗?不。@user962206您可以在PHP变量中的任何位置回显它。。。如果希望它是mp3,则可能需要在脚本中指定它是mp3,而不是m4a。
对于单个php行不是必需的,如何。更改构造函数?如果文件不是m4a,则与之类似。它不会使用m4a。它会用mp3吗?@diEcho我习惯于放一个
所以我总是把它放在我的代码中。它不会影响输出,是吗?不。@user962206您可以在PHP变量中的任何位置回显它。。。如果希望它是mp3,则可能需要在脚本中指定它是mp3,而不是m4a。