For anyone else running into this error, please make sure you have <?php wp_footer(); ?> in your footer.php and <?php wp_head(); ?> in your header.php. It’s a pretty rookie mistake that didn’t pop anywhere else for me and that’s what was causing the issue.
The problem was that html() in jquery doesn’t support line breaks and this is how I fixed it with PHP:
$original_post_content = get_the_content();
$breaks = array(“\r\n”, “\n”, “\r”);
$post_content = str_replace($breaks, “
“, $original_post_content);
It basically removes any line breaks and replaces them with
s