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

  • Home
  • SEARCH
  • 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 9179323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:46:06+00:00 2026-06-17T17:46:06+00:00

I hit a problem when I store the html below into a div via

  • 0

I hit a problem when I store the html below into a div via ajax

<script type="text/javascript" src="site.com/file.js"></script>
<script type="text/javascript">
//use file.js object, get an exception because it doesn't exist

I fixed it by hosting it locally (/myjs/file.js). However that feels like its a hack. How do I make sure I load it first then execute? It seems like jquery.ready isn’t the solution because the dom was ready before I ajax the html in. How do I wait properly?

  • 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-17T17:46:07+00:00Added an answer on June 17, 2026 at 5:46 pm

    You mention jQuery.ready, so I’m guessing you use jQuery. If so, instead of putting <script> tags in the content of the div, use jQuery.getScript, which will give you a callback when the script is loaded.

    If for some reason you can’t do that, you can poll, e.g. in your code that wants to use something from file.js:

    function doSomethingWithFileJS() {
        if (typeof anObjectProvidedByFileJS === "undefined") {
            setTimeout(doSomethingWithFileJS, 50);
            return;
        }
    
        // Here, you know file.js has been loaded
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem fixed, see below What I'm doing is this: Generate random number -> store
When searching the iTunes store, I've hit a little problem. I'm trying to change
I've hit this problem recently, and I've been stuck at it for a few
I'm hit a problem when attempting to deploy a MVC app as a sub-application
I'm new to python and have hit a problem with an SQL query I'm
I'm just playing around with FastMember and have hit a problem. Each time I
I was just playing around with IOS and I hit a problem and it
I'm writing a C# game engine for my game, and I've hit a problem.
I've hit an annoying problem in LaTeX. I've got a tex file of about
I have hit a real problem. I need to do some Kmeans clustering for

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.