John Davidson

JQuery .html() insertion method won't take PHP file_get_contents() as an argument


Here is the code:

echo "<script>jQuery(document).ready(function($)
{ $('.page-id-24 .entry-content').html('" . file_get_contents('about.php') . "'); });</script>";

Note: In my about.php file it has: <?php echo "html content..."; ?>

Results: I get nothing.

What's wrong? What am I not understanding?

My Answer:
't work if the element you are trying to insert into doesn't exist in the DOM. You can use the .append() or .prepend() methods instead to insert content into an existing element or create a new element and insert content into it before adding it to the DOM.

Rate this post

3 of 5 based on 8508 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us