Я работал над проектом, который динамически создает файл javascript с использованием ASP.NET, который вызывается с другого сайта.
Этот файл jquery javascript добавляет div и заполняет его довольно большим сегментом HTML, и для этого мне нужно превратить сегмент в строку, например:
$(document).ready(function(){
var html = "Giving this magazine such a lofty epithet may seem a bit presumptuous, but for a non scientifically trained outsider this magazine offers a fresh and challenging look at the fast paced world of science that doesn't shy away from humor and the use of terms and ideas that may require its readers to go online and define a term. And in some cases it may inspire the reader to pick up a book on science by such greats as Hawking and Greene in order to better grasp some of the concepts dealing with time, space and atoms. This magazine isn't dumbed down. It includes well placed and efficient illustrations to help explain some of the more abstract points. It is not designed in the way popular magazinea are, in so much as they only touch upon a topic in the simplest manner and then move on before the audience is lost. Yet this magazine keeps the attention of the reader by combining explanatory notes that help people with no background knowledge have some grasp of the topic and by using humor and well written articles to clearly make their points. <br />For a magazine with a serious and well researched list of topics having small cartoons the likes of the New Yorker shows how comfortable this magazine is with itself. From the moment I picked up this magazine for the first time I felt like every word I read mattered and was worth my time to read. (Not true of many other magazines) American Scientist may not have the audience of Discover or National Geographic, nor is it as accessible as said titles, but for those with a true interest in science willing to challenge themselves and commit to real learning this magazine may be a perfect fit. At $4.95 it is certainly worth it to pick a copy on the news stand and try it out."
$("#divname").append(html);
});
Как видите, сегмент будет довольно большим, и у меня нет возможности узнать, насколько он велик, поскольку он генерируется динамически из моей базы данных, в зависимости от идентификатора reviewID, который определяется пользователем в его запросе.
HTML-код, который будет вставлен в div, представляет собой список обзоров и генерируется с использованием asp.net MVC повторителем, который просматривает список. (если это поможет вам понять, что я делаю).
Есть ли способ превратить этот большой сегмент в одну строку, которую можно вставить в скрипт добавления?
Спасибо