Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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
Javascript JPlayer-将字符串值发送回php_Javascript_Php_Jquery_Jplayer - Fatal编程技术网

Javascript JPlayer-将字符串值发送回php

Javascript JPlayer-将字符串值发送回php,javascript,php,jquery,jplayer,Javascript,Php,Jquery,Jplayer,我需要帮助来修改这个脚本。这个JPlayer脚本从一个getsong.php文件获取其URL数据,该文件工作正常,但我需要将一个字符串值发送回getsong.php文件,例如: php?摇滚乐 或 php?流行音乐 我需要发送这个字符串值吗?使用这些OnClick链接: 这是当前的jplayer脚本: <script type="text/javascript"> var dataString_code $(function() { $(".new_string").click(

我需要帮助来修改这个脚本。这个JPlayer脚本从一个getsong.php文件获取其URL数据,该文件工作正常,但我需要将一个字符串值发送回getsong.php文件,例如:

php?摇滚乐

php?流行音乐

我需要发送这个字符串值吗?使用这些OnClick链接:

这是当前的jplayer脚本:

<script type="text/javascript">

var dataString_code

$(function() {
$(".new_string").click(function() {
var code = $("#code").val();
dataString_code = 'code='+ code;

return true;
});
});


$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        var data = $.ajax({
          url: "getsong.php?"+ dataString_code,
          async: false
         }).responseText;

        string = data.split('|');
        $(this).jPlayer("setMedia", {
            mp3: string[0]
        }).jPlayer("play");

        $('ol#artist').html(string[1]);
        $('ol#songname').html(string[2]);

    },
    ended: function (event) {  
        var data = $.ajax({
          url: "getsong.php?"+ dataString_code,
          async: false
         }).responseText;

        string = data.split('|');
        $(this).jPlayer("setMedia", {
            mp3: string[0]
        }).jPlayer("play");


        $('ol#artist').html(string[1]);
        $('ol#songname').html(string[2]);

    },
    swfPath: "js",
    supplied: "mp3"

});
});

</script>
请帮忙


谢谢。

哈哈,好的:您正在调用函数onclick=new\u string'code=rock',它会触发函数的执行。完美的 但该函数未定义,例如

var new_string = function(ev) {

}
相反,您使用的是: $.new_string.clickfunction{ 它会将一个新的onClickHandler附加到一个不存在的元素上,您正在使用jQuery.classname的类selektor,就我所见,没有一个元素具有类new\u string。 因此,您可以:

<a href="#" class="new_string">Rock</a>

 $(".new_string").click(function() {
    var oThis = $(this); // this points to the "a" - DOM - element
    var code = oThis.html();
    dataString_extra = 'code='+ code;

    return true;
  });

<a href="#" class="new_string">Rock</a>

 $(".new_string").click(function() {
    var oThis = $(this); // this points to the "a" - DOM - element
    var code = oThis.html();
    dataString_extra = 'code='+ code;

    return true;
  });
<a href="#" onclick="new_string('code=rock')">Rock</a>

var new_string = function(code) {
     dataString_extra = code;

    return true;
}