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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:20:32+00:00 2026-05-20T22:20:32+00:00

I was using jQuery.load() to load a html page’s content into a lightbox. The

  • 0

I was using jQuery.load() to load a html page’s content into a lightbox. The most useful thing load does in this instance is turning full html pages into a clean html fragment to be inserted into the page.

But (because of a buggy 3rd party API which won’t work when loaded dynamically), I need to first use a regex to filter out one or two elements from the page before it gets processed as html, which means I need to use the dataFilter option of $.ajax.

So now that I’m using $.ajax instead of .load I need to convert my filtered text into the clean html that .load delivers automatically

But $(response) generates a strange buggy jQuery object where .find(), children() etc… don’t work.

Can anyone tell me how to get the clean html I need (I notice the ajax code injQuery has changed a lot from v 1.4.4 to 1.5 – a solution using either version would do)

Here’s what I have so far (using jQuery 1.4.4) (all the variables and methods referenced are defined above this code)

 $.ajax({
            url: url,
            type: "GET",
            dataType: "html",
            dataFilter: function (response) {
                return response.replace(recaptchaRegex, "");
            },
            success: function (response) {
                // If successful, inject the HTML into all the matched elements
                // See if a selector was specified
                destination.html($(response).children("#lightBoxForm"));

                callback();
            }
        });
  • 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-20T22:20:32+00:00Added an answer on May 20, 2026 at 10:20 pm

    Well I see this was asked a while ago but hopefully this will still be helpful to you. From your question I understand you want to replicate the $.load function with the $.ajax function instead.

    A tool you might find useful to use in the future is the jQuery source viewer so you can see exactly how jQuery is doing things under the hood.

        // Using jquery 1.5.1
        $(function () {
    
            var rscript = "/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi";
    
            // Will override all ajax requests on this page including load
            $.ajaxSetup({
                dataFilter: function (response) {
                    return response.replace("Lorem ipsum.", "");
                },
                type: "GET",
                dataType: "html",
                // Disable caching of AJAX responses for example only
                cache: false
            });
    
            $("#load").click(function (evt) {
                evt.preventDefault();
                $('#content').load("html.htm #lightBoxForm");
            });
    
            $("#ajax").click(function (evt) {
                evt.preventDefault();
    
                $.ajax({
                    url: "html.htm",
                    success: function (res) {
                        $("#content").html("#lightBoxForm" ?
                                $("<div>").append(
                                            res.replace(rscript, ""))
                                               .find("#lightBoxForm") : res);
                    }
                });
    
            });
    
        });
    

    And my html

       <input type="button" id="load" value="Load" />
       <input type="button" id="ajax" value="Ajax" />
    
       <div id="content"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the jquery library to load the content of an html file. Something
I have a simple html page with a div. I am using jQuery to
I'd like to inject jQuery into a page using the Google AJAX Libraries API,
I am using jQuery for a simple website and have a main page 'index.html'
I am using the Quicksand jquery scripts on an HTML page and using simple
Im using jQuery/PHP/MySql to load twitter search results on the page but limited to
I'm using jQuery to create a load of tabs for a web application. I've
I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
I am relatively new to using jQuery and would like to use the load
I ran into a bit of trouble while trying to load an external HTML

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.