Json jQuery连续循环水平股票行情器

Json jQuery连续循环水平股票行情器,json,jsf,jquery,jquery-plugins,Json,Jsf,Jquery,Jquery Plugins,我在jStockticker的html页面中有以下内容 <div id="ticker" class="stockTicker" style="width: 100%"> <span class="quote">Stock Quotes: </span> <span id="tickerValues-AAPL"> <span class="up"> &

我在jStockticker的html页面中有以下内容

<div id="ticker" class="stockTicker" style="width: 100%">
    <span class="quote">Stock Quotes: </span>
        <span id="tickerValues-AAPL">
              <span class="up"> 
                <span class="quote">AAPL</span>
                462.12
              </span>
          <span class="down">
                <span class="quote">AAPL</span>
            232.32
               </span>
          <span class="eq"> 
                 <span class="quote">AAPL</span>
          451.52
              </span>
        </span>
            <span id="tickerValues-GOOG">
              <span class="up"> 
                <span class="quote">GOOG</span>
                623.12
              </span>
          <span class="down">
                <span class="quote">GOOG</span>
            502.32
               </span>
          <span class="eq"> 
                 <span class="quote">GOOG</span>
          545.52
              </span>
        </span>
    </div>

股票报价:
AAPL
462.12
AAPL
232.32
AAPL
451.52
谷歌
623.12
谷歌
502.32
谷歌
545.52
通过jQuery,我可以用ajax更新实时值

$(document).ready(function() {
  $("#ticker").jStockTicker({interval: 45});


         var i = setInterval(function ()
                {

                    $.ajax({
                          type : "POST",
                          url : 'http://localhost:8080/Data.xhtml',
                          dataType : "json",

                          success: function(data) {   

                                    $.each(data, function(i, item) {

                                       if(data[i].LastT == "+"){
                    $("span[id*='tickerValues-"+data[i].Symbol+"']").html("<span class=\"up\"><span class=\"quote\">"+data[i].Symbol+"</span> "+data[i].LastTPrice+"</span>");
                               }else if(data[i].LastT == "-"){
                            $("span[id*='tickerValues-"+data[i].Symbol+"']").html("<span class=\"down\"><span class=\"quote\">"+data[i].Symbol+"</span> "+data[i].LastTPrice+"</span>");
                   }else if(data[i].LastT == " "){
                    $("span[id*='tickerValues-"+data[i].Symbol+"']").html("<span class=\"eq\"><span class=\"quote\">"+data[i].Symbol+"</span> "+data[i].LastTPrice+"</span>");
                   }
                                    }); 

                                  $("#ticker").jStockTicker({interval: 45});

                                  },
                          error : function() {
                            alert("");
                          }
                        });
                    return false;
                }, 6000);

}); 
$(文档).ready(函数(){
$(“#ticker”).jStockTicker({interval:45});
变量i=设置间隔(函数()
{
$.ajax({
类型:“POST”,
网址:'http://localhost:8080/Data.xhtml',
数据类型:“json”,
成功:函数(数据){
$。每个(数据、功能(i、项){
如果(数据[i].LastT==“+”){
$(“span[id*='tickerValues-“+data[i].Symbol+”].html(“+data[i].Symbol+”“+data[i].LastTPrice+”);
}else if(数据[i].LastT==“-”){
$(“span[id*='tickerValues-“+data[i].Symbol+”].html(“+data[i].Symbol+”“+data[i].LastTPrice+”);
}else if(数据[i].LastT==“”){
$(“span[id*='tickerValues-“+data[i].Symbol+”].html(“+data[i].Symbol+”“+data[i].LastTPrice+”);
}
}); 
$(“#ticker”).jStockTicker({interval:45});
},
错误:函数(){
警报(“”);
}
});
返回false;
}, 6000);
}); 

问题是当更新发生时,股票代码滚动回到开始并开始滚动,而不是在连续滚动时获取更新值。

我意识到这是一篇旧文章,但可能是这里看到的工具。。。可能更符合您的喜好。

我可能错了,但是,您不应该使用ajax获取一些servlet(或硬编码的xml/json)吗?您可以用两种方法来代替xhtml,这样就不会影响这一点