In the following JavaScript code, when I pass the message is too big that spans more than one screen width, message is being truncated. I have put the alert statements and found out that the whole message is coming from web method to javascript code, but while displaying it, it is truncating the messsage. Since I am novice to JavaScript (this code is concoction of code bits I got from the web), any help is greatly appreciated. Thank you in advance for your help.
$(document).ready(function() {
//initialize ul;
$("#scroller").html("");
var tkhtml = '';
var successReq = false;
$.ajax({
type: "POST",
url: "GetDataFromWebMethod.aspx/GetDataForTicker",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var y = msg.d;
var x = y.split('~');
alert(x.length);
if (x != '') {
for (n = 0; n < x.length; n++) {
tkhtml = tkhtml + '<li>' + x[n] + '</li>';
}
alert(tkhtml);
$("#scroller").html(tkhtml);
successReq = true;
}
},
error: function(msg) {
alert("Entered Failure");
}
});
var successReq = false;
var interval = setInterval(function() {
if (successReq) {
clearInterval(interval);
javacode();
}
}, 100);
function javacode() {
var speed = 2;
var items, scroller = $('#scroller');
var width = 0;
scroller.children().each(function() {
width += $(this).outerWidth(true);
});
scroller.css('width', width);
scroll();
function scroll() {
items = scroller.children();
var scrollWidth = items.eq(0).outerWidth();
scroller.animate({ 'left': 0 - scrollWidth }, scrollWidth * 100 / speed, 'linear', changeFirst);
}
function changeFirst() {
scroller.append(items.eq(0).remove()).css('left', 0); scroll();
}
}
});
My css is:
<style type="text/css">
#scroller { height: 100%; margin: 0; padding: 0; line-height: 30px; position: relative; }
#scroller li { float: left; height: 30px; padding: 0 0 0 10px; list-style-position: inside; }
#scrollerWrapper { height: 30px; margin: 30px; overflow: hidden; border: 1px #333 solid; background: #F2F2F2; }
</style>