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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:34:51+00:00 2026-05-25T03:34:51+00:00

i have an ajax engine based on jQuery. And after receiving the response i

  • 0

i have an “ajax engine” based on jQuery. And after receiving the response i must manipulate the response before inserting in page. But I need the response as an jQuery object.
I do this with:

tmpActualResult = $( '<span/>' ).html( actualResult );

But at this time jQuery (or browser itself?) execute the scripts which are included in response – and exactly this shouldn’t occur. I will execute the scripts manual later.

in particular I will:

  1. parse response (get access to the tags/elements which are included)
  2. insert the elements into page (DOM manipulating)
  3. execute possible scripts (which are received)

in thanks

Edit:
If someone is interested too, i’ve created a more general solution by extending the jQuery.domManip function, as suggested in first answer.

(function($, oldDomManip) {
// Override the core domManip function
$.fn.domManip = function() {

    function evalScript(i, elem) {
        jQuery.globalEval(elem.text || elem.textContent || elem.innerHTML || "");
    }

    var scripts = [];
    // let jQuery build the fragments
    var results = jQuery.buildFragment(arguments[0], this, scripts);
    // change parameter to created fragments
    arguments[0] = results.fragment.childNodes;
    // do what jQuery will do - without scripts
    oldDomManip.apply(this, arguments);
    if (scripts.length) {
        // if connection is active
        if (jQuery.active != 0) {
            $(this).bind("ajaxStop.scriptCache", function() {
                $.each(scripts, evalScript);
                $(this).unbind("ajaxStop.scriptCache");
            });
        } else
            $.each(scripts, evalScript);
    }
    return this;
};
})(jQuery, jQuery.fn.domManip);

it will not execute scripts before ajax request is completed. worked for me.

  • 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-05-25T03:34:52+00:00Added an answer on May 25, 2026 at 3:34 am

    You can’t prevent script execution of scripts that are part of a string of markup you’re trying to add using .html() or .append(). At least not without extending the domManip function of jQuery. It extracts all scripts in html markup that you’re trying to add using .html() or .append() and evals it.

    You could, however, extract the script tags with their inner text (js) from the string yourself, add only the markup via .html() or .append() and then eval the scripts yourself when you need to.

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

Sidebar

Related Questions

I have tons of ajax components on this booking engine. I need to customize
I have heard about APE (ajax push engine) to make realtime notifications but I
I have a series of dynamically generated inputs that I need to have ajax
With ASP.NET MVC, it is common to have AJAX code(e.g. jQuery) to invoke web
I have an ajax toolkit TabContainer control on my page with a couple tabs.
I have an ajax search engine. If none of the filters are on, I
Suppose I have performed an AJAX call with jQuery in the following fashion: key
I have this AJAX request: $(#searchagain_form).submit(function() { $.ajax({ type: 'POST', url: /searchforward, data: {engine:
I just learned about the AJAX Push Engine but it runs on Linux/Apache which
I have been trying to set-up an Ajax Push Engine (APE) Server in a

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.