0

I have following in the html page for the jStockticker.

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

and with jQuery im updating the real time values with 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);

}); 

The issue is when an update occur the ticker scrolling goes back to the beginning and starts scrolling rather than getting the updated value while scrolling continuously.

4

1 回答 1

0

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

于 2013-10-09T15:06:06.950 回答