试图将jQuery转换为原型... jQuery导致问题

时间:2014-10-27 01:00:34

标签: javascript php jquery ajax prototypejs

我有以下代码:

<script type='text/javascript' src='js/jquery.js'></script>
            <script type='text/javascript'>
    var last_song = '$song[1]';
    var jqy = jQuery.noConflict()
    var change_radio = setInterval(function ()
    {
        jqy.ajax({
            url : 'modules/ajax/refresh.php',
            type : 'GET',
            data : {lastsong: 'last_song'},
            success: function(data)
            {
                last_song = data;
                jqy('#radio').html(last_song);
            }
        });
    }, ($refresh*1000));
    change_radio;
</script>

refresh.php

<?php 
    $lastsong = $_GET['lastsong'];
    $timeout = "2"; // Number of seconds before connecton times out.
    $ip[1]   = "198.101.13.110"; // IP address of shoutcast server
    $port[1] = "8000"; // Port of shoutcast server
    //$song = [];
    //$msg = [];
    //END CONFIGURATION
    $servers = count($ip);
    $i       = "1";
    while ($i <= $servers)
    {
        $fp = @fsockopen($ip[$i], $port[$i], $errno, $errstr, $timeout);
        if (!$fp)
        {
            $listeners[$i] = "0";
            $msg[$i]       = "<span class=\"red\">ERROR [Connection refused / Server down]</span>";
            $error[$i]     = "1";
        }
        else
        {
            fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
            while (!feof($fp)) $info = fgets($fp);
            $info  = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
            $info  = str_replace('</body></html>', "", $info);
            $stats = explode(',', $info);
            if (empty($stats[1]))
            {

                $listeners[$i] = "0";
                $msg[$i]       = "<span class=\"red\">ERROR [There is no source connected]</span>";
                $error[$i]     = "1";
            }
            else
            {
                if ($stats[1] == "1")
                {
                    $song[$i]      = $stats[6];
                    $listeners[$i] = $stats[4];
                    $max[$i]       = $stats[3];
                    // Both IFs the same? Please check that and make one only if its the case
                    if ($stats[0] == $max[$i]) $msg[$i] = "<span class=\"red\">";
                    if ($stats[0] == $max[$i]) $msg[$i] .= "</span>";
                }
                else
                {
                    $listeners[$i] = "0";
                    $msg[$i]       = " <span class=\"red\">ERROR [Cannot get info from server]</span>";
                    $error[$i]     = "1";
                }
            }
        }
        $i++;
    }
    if($song[1] != "")
    {
        echo $song[1];
        exit();
    }
    echo uriencode($lastsong);

?>

我想改为使用原型代替。我已经使用了原型和jQuery,这与写的有冲突。我不知道从哪里开始,但任何帮助都会受到赞赏......特别是因为在我的情况下有很多人。非常感谢。

0 个答案:

没有答案