Estoy tratando de jquery para devolver el valor de php dentro de div Estoy usando .html () pero obtuve Uncaught SyntaxError: identificador inesperado mi código html es:
<script> $( document ).ready(function() $('#post-msg-<?= $divId ?>').html(`<?= \humhub\actions\TextFormatAction::text_html($model->message) ?>`); }); </script>en el elemento de inspección veo que mi código php es:
$( document ).ready(function() { $('#post-msg-e369853df766fa44e1ed0ff613f563bd').html('<p></p><img src="http://127.0.0.1/index.php?file=d2dd907d-bfd4-40ab-832f-bd8c161fd60e+" alt="" title="" /> <p> <div class="div-div"> <div> <div class="div-title-description"> <h2> <span class="div-title">Title-text</span> </h2> <p class="div-description">Description - text </p> </div> </div> </div> </p> '); });Esta es la forma en que debería verse el trabajo. No debe tener saltos de línea en HTML desde la función html .
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body> <script> $( document ).ready(function() { $('#post-msg-e369853df766fa44e1ed0ff613f563bd').html('<p></p><img src="http://127.0.0.1/index.php?file=d2dd907d-bfd4-40ab-832f-bd8c161fd60e+" alt="" title="" /><p><div class="div-div"><div><div class="div-title-description"> <h2> <span class="div-title">Title-text</span> </h2> <p class="div-description">Description - text </p> </div> </div></div></p>'); }); </script> </body> <div id="post-msg-e369853df766fa44e1ed0ff613f563bd"> </div> </html>