John Davidson

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

0 comments
Message:


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

5 of 5 based on 6304 votes

Comments




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