Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:25:43+00:00 2026-06-03T03:25:43+00:00

I am loading piece of page that contains some javascript code as well, and

  • 0

I am loading piece of page that contains some javascript code as well, and $.getScript() approach wont work here as some of the javascript code is dynamically build through php.

<div id="fetch-me">
...
<script...>
var posts = <?php .... ?> 
...
</script>
</div>

As you might be familiar with this kind of issue, once I load this div with:

$("#load-me").load("... #fetch-me"); 

Javascript is not usable. I need to execute obviously. And I’ve tried few things but with no success. As an example this:

$("#load-me").load("... #fetch-me", function(){
 eval($("#load-me").find("script").text());
}); 

Any help appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:25:46+00:00Added an answer on June 3, 2026 at 3:25 am

    load will return you the data it loaded in its callback. Try to get the script(s) and append them to a <script> tag.

    $("#load-me").load("... #fetch-me", function(data){
        $('<script>').html($(data).filter('script').html()).appendTo('head');
    });
    

    If there are multiple script tags in the loaded page, that may not work. If that’s the case, try this:

    $("#load-me").load("... #fetch-me", function(data){
        $(data).filter('script').each(function(){
            $('<script>').html($(this).html()).appendTo('head');
        });
    });
    

    P.S. If this doesn’t work, try changing .filter to .find.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following piece of code in the page HEAD: <script type=text/javascript> $(document).ready(function(){
I am a bonifide jQuery novice and I have some jquery code that I
So imagine a piece of Javascript as the first script on a page along
I've taken a piece out of some of the major caching/image loading methods people
I have WebView which loads some page, when it's finished I apply some javascript
I have written a small piece of code regarding the dynamic loading of assemblies
I have some code that I've inherited, and it's not the greatest in the
I am loading a piece of html via ajax. Once the load is complete
When loading a page for the first time (!IsPostback), I am creating a button
I have the following piece of code: try{ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.