在这段代码中,我将 PHP var 传递给 javascrip 以在 div 元素中显示它。当字符串少于 50 个字符时,它工作得很好,但是当它有点长时它会崩溃。这是我的代码:
$sql3 = "SELECT * FROM $table2 WHERE id = '$newsId'";
$result3 = mysql_query($sql3);
$thisNews = mysql_fetch_array($result3);
?>
newsContent = "<? echo $thisNews['news']; ?>";
newsDiv = "<div class='newsBox'>";
newsDiv += "<div class='newsTitle'><? echo $rowArray[$i]['title']; ?></div>";
newsDiv += "<div class='newsBody'>"+newsContent+"</div>";
newsDiv += "<div class='newsFoot'>autor: <? echo $thisNews['author']; ?> - <? echo $thisNews['site']; ?> - <? echo $thisNews['source']; ?></div>";
box.append(newsDiv);