【问题标题】:jQuery Horizontal Stock Ticker with Continuous looping具有连续循环的 jQuery 水平股票行情
【发布时间】:2012-05-01 23:45:12
【问题描述】:

我在 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>

并使用 jQuery im 使用 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);

}); 

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

【问题讨论】:

  • 我可能错了,但是,您不应该对某些 servlet(或硬编码的 xml/json)执行 ajax GET 吗?而不是 GET 到 xhtml?
  • 你可以同时做这两种方式,所以它不会影响这个

标签: json jsf jquery jquery-plugins


【解决方案1】:

我知道这是一篇旧帖子,但也许这里看到的工具...http://www.bitbenderz.com/stockticker/index.html...可能更符合您的喜好。

【讨论】:

    猜你喜欢
    • 2015-07-12
    • 1970-01-01
    • 2011-05-29
    • 2011-11-10
    • 2018-07-05
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    相关资源
    最近更新 更多