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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:39:05+00:00 2026-06-06T18:39:05+00:00

I want to retrieve HTML and Javascript from the same page using AJAX calls.

  • 0

I want to retrieve HTML and Javascript from the same page using AJAX calls. However, I’m not sure what the best, cleanest, and safest way to do this is. I want my Javascript to edit an already defined object on the client. So far, my idea is:

Client-side script executed on some event:

getMoreStuff = function () {
  $.ajax({
    url: '/someRoute',
    success: function (data) {
      $data = $(data);
      $things = $data.find('#things');
      $('#content').append($things);
      // Execute the script
    }
  })
}

Body of AJAX request:

<div id="things">
  <div class="post">...</div>
  <div class="post">...</div>
  <div class="post">...</div>
  <div class="post">...</div>
  <div class="post">...</div>
</div>
<script>
  (function() {
    window.things || (window.things = []);
    things.concat([...some array...]);
  })();
</script>

I’m not sure if my jQuery code executes it when I define $data. Or should I send the script as a string and use eval?

Would this work?

$(document.body).append($data.find('script'));
  • 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-06T18:39:05+00:00Added an answer on June 6, 2026 at 6:39 pm

    See dataType here

    “html”: Returns HTML as plain text; included script tags are evaluated
    when inserted in the DOM.

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

Sidebar

Related Questions

I have a HTML table as follows. I want retrieve row values from this
I want to retrieve data from restful webservice that returns xml. I'm using phonegap.
I've got a dynamic html table and I want to retrieve the data from
I want to process an array from java script. (i.e., from html page to
I want to retrieve the pure text (without any HTML) of the description of
I want retrieve the width and height of browser in pixel(px) using ruby code.
I want to retrieve the last 3 registered users in cakephp using the field
I want to retrieve all ids within a certain timespan. The timestamps however, are
I have two XML sources to retrieve data from. I want to use them
I want my HTML page to load like normal, but I want one section

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.