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 8099693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:29:36+00:00 2026-06-05T22:29:36+00:00

I am using the following way in order to insert an external html page

  • 0

I am using the following way in order to insert an external html page into my div:

      $.ajax({
          url: "myHTML.html",
          method: 'GET',
          success: function (data) {
              $("#outputDiv").html(data);
          },
          Error: function (err) {
              alert("ERROR: " + err);
          }
      });

which works fine,
the issue is that I would like to run some JavaScript functions that are located in the “myHTML.html” file,
Is there a way to do something like that?

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-05T22:29:40+00:00Added an answer on June 5, 2026 at 10:29 pm

    It’s often much easier to keep scripts in the page you are loading the content into. This is especially true if you have a group of files that all use the same ajx to load, and all call the same functions. This alleviates need to change multiple files with code revisions.

    $.ajax({
          url: "myHTML.html",
          method: 'GET',
          success: function (data) {
              $("#outputDiv").html(data);
              /* new html exits so can run code here that affects it*/
              newHtmlAdded();
          },
          error: function (err) {/* note typo on capital "E" fixed*/
              alert("ERROR: " + err);
          }
      });
    
      function newHtmlAdded(){
           fixmFormStyle();
           addMyValidation(); 
          doSomethingElse();
      }
    

    Otherwise, it’s important to realize that the ready event has already occurred in page being loaded into. This means any code wrapped in ready handler will fire immediately. If the code is before the html in the remote file, it will fire before the corresponding html elements exist in the DOM…and will do nothing.

    Code placed after the html in the remote file will work, since the html it refers to will have already been proceessed

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

Sidebar

Related Questions

Is there a better way of writing the following method? Using LINQ maybe? Instead
I tried to reuse the .pch to speed the build using the following way:
I've been using ShowDialog() in following way for all my new Windows. SomeGui test
I am using apache ant in the following way: I have projects P1, P2,
I am using the following class written by Mark Brittingham for two way AES
Using C# I was trying to develop the following two. The way I am
Using following code I try to get updated list of checkbuttons' corresponding text values,
In PHP, I create and execute SQL queries like the following. INSERT INTO Table
Using Nitrogen, the Erlang web framework , I have the following method that receives
I have a database that I have populated using CREATE and INSERT INTO statements.

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.