javascript - How do I use jQuery new advanced ticker to read text from text file? -


i'm trying code in website:

<script> var file = "http://newsxpressmedia.com/files/theme/test.txt"; function getfile(){     $.get(file,function(txt){         var lines = txt.responsetext.split("\n");         (var = 0, len = lines.length; < len; i++) {             save(lines[i]);           <ul class="newsticker">lines[i]</ul>         }     });  } </script> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://newsxpressmedia.com/files/theme/jquery.newsticker.js"></script>  <script> $('.newsticker').newsticker({     row_height: 48,     max_rows: 2,     speed: 6000,     direction: 'up',     duration: 400,     autostart: 1,     pauseonhover: 0 }); </script> 

but don't see anything. text suppose scroll up.

in original code was:

<ul class="newsticker">     <li>etiam imperdiet volutpat libero eu tristique.</li>     <li>curabitur porttitor ante eget hendrerit adipiscing.</li>     <li>praesent ornare nisl lorem, ut condimentum lectus gravida ut.</li>     <li>nunc ultrices tortor eu massa placerat posuere.</li> </ul> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://newsxpressmedia.com/files/theme/jquery.newsticker.js"></script>  <script> $('.newsticker').newsticker({     row_height: 48,     max_rows: 2,     speed: 6000,     direction: 'up',     duration: 400,     autostart: 1,     pauseonhover: 0 }); </script> 

what doing wrong ? checked file test.txt exist , can read code :

<script>     var file = "http://newsxpressmedia.com/files/theme/test.txt";     function getfile(){         $.get(file,function(txt){             var lines = txt.responsetext.split("\n");             (var = 0, len = lines.length; < len; i++) {                 save(lines[i]);               <ul class="newsticker">lines[i]</ul>             }         });      }     </script> 

is not working don't see anything. tried add in loop line:

<ul class="newsticker">lines[i]</ul> 

but guess it's wrong.

edit**

the code this:

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="http://newsxpressmedia.com/files/theme/jquery.newsticker.js"></script>  <script> $(function() {     var file = "http://newsxpressmedia.com/files/theme/test.txt";     $.get(file, function (txt) {         var lines = txt.responsetext.split("\n");         $ul = $('<ul class="newsticker" />');         (var = 0, len = lines.length; < len; i++) {             //save(lines[i]); // not sure             $ul.append('<li>' + lines[i] + '</li>');         }         $ul.appendto('body').newsticker({             row_height: 48,             max_rows: 2,             speed: 6000,             direction: 'up',             duration: 400,             autostart: 1,             pauseonhover: 0         });     }); }); </script> 

but nothing don't see text @ all.

edit**

opend console dev on website at: http://newsxpressmedia.com/ , see text in console:

6 consider using 'dppx' units instead of 'dpi', in css 'dpi' means dots-per-css-inch, not dots-per-physical-inch, not correspond actual 'dpi' of screen. in media query expression: screen , (-webkit-min-device-pixel-ratio: 2), not all, not all, not all, screen , (min-resolution: 192dpi), screen , (min-resolution: 2dppx) (index):1 uncaught typeerror: cannot call method 'split' of undefined (index):101 event.returnvalue deprecated. please use standard event.preventdefault() instead.

you have 2 issues. first need create li elements , append them dom. second aren't waiting ajax call finish before setting newsticker plugin. don't see reason have getfile function:

$(function() {     var file = "http://newsxpressmedia.com/files/theme/test.txt";     $.get(file, function (txt) {         var lines = txt.responsetext.split("\n");         $ul = $('<ul class="newsticker" />');         (var = 0, len = lines.length; < len; i++) {             //save(lines[i]); // not sure             $ul.append('<li>' + lines[i] + '</li>');         }         $ul.appendto('body').newsticker({             row_height: 48,             max_rows: 2,             speed: 6000,             direction: 'up',             duration: 400,             autostart: 1,             pauseonhover: 0         });     }); }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -