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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:46:41+00:00 2026-05-17T21:46:41+00:00

I have got below JQuery where I am performing the .load function. $(.load-fragment).each(function() {

  • 0

I have got below JQuery where I am performing the .load function.

$(".load-fragment").each(function()         
        {          
            var $objThis = $(this);
            var fname = $objThis.attr("href"); //Getting the href of the element
            var dynDivID = "divContent"+ $objThis.attr("id");  //Name of the dynamic div ID
            var newDiv = $("<div>").attr("id",dynDivID)
            .load(fname+ " #tab-container", {pupdate:"true"},function(response, status, xhr) 
            {
                if ( $(response+".formContainer").length) 
                {
                    $objThis.removeClass('load-fragment');                                                    
                }     
                if (status == "error") 
                {               
                    newDiv.removeClass('dynDiv');
                    newDiv.addClass('errorDiv');
                }
            })//Loading page fragment from the given link
            .hide()//Hiding all the newly created DIVs
            .addClass('dynDiv')//Adding CSS to newly created Dynamic Divs
            .append($('<img/>').attr({ src: '/system/Images/ajax-loader-circle-thickbox.gif', alt: '', style:'margin:50px 0px 50px 185px' }));//Adding the loading.gif file
            $("#container-4").append(newDiv);//adding new div in div column2
        }); 

In a .load function above, I am trying to load page fragment from the linked page. I am getting the response in a below html format.

<div class="tabs-container" id="tab-container">
    <div class="contentContainer">
        <div class="contentContainer">
            <p>
                Book your New Delhi flights with Emirates and experience our award-winning service
                flying direct to Australia's most iconic city.</p>
        </div>
    </div>
    <div class="formContainer">
        <p>Testing</p>
    </div>
</div>

Now I want to check in response text whether there formContainer class exists inside the response or not and then perform certain work. Below is the code I am trying but it is not working for me.

 .load(fname+ " #tab-container", {pupdate:"true"},function(response, status, xhr) 
                {
                    if ( $(response+".formContainer").length) 
                    {
                        $objThis.removeClass('load-fragment');                                                    
                    }     
                    if (status == "error") 
                    {               
                        newDiv.removeClass('dynDiv');
                        newDiv.addClass('errorDiv');
                    }
                })

Please suggest!

  • 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-17T21:46:42+00:00Added an answer on May 17, 2026 at 9:46 pm

    You can just wrap that HTML snippet into a jQuery object and use it’s DOM methods.

    if( $(response).filter('#tab-container').find('.formContainer').length ) {
       // class .formContainer was found
    }
    

    Here I’m using the .filter() method to grab the #tab-container div. You can’t use .find() unless you wrap that complete snippet into another self-created div for instance. In this particular case, you could even use $(response).first().find()..., but .filter() is more reliable there.

    Another way (which is faster, but not recommendable unless to know exactly what you do & transfer) is to use a plain Javascript .indexOf() on your response.

    if( response.indexOf('class="formContainer"') > -1 ) {
       // class .formContainer was found
    }
    

    Reference: $(), .find(), .filter()

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

Sidebar

Related Questions

So far i have got the code below which works lovely when trying an
I have got a C function in a static library, let's call it A,
I have got some code to load an assembly and get all types, which
I have got this error when using Enterprise Library 3.1 May 2007 version. We
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
We have got loads of options for php + MySQL + Apache combo... Which
I have got a python script which is creating an ODBC connection. The ODBC
I have got the following problem since the server has safe mode turned on,
I have got the following code from here to read an Excel file using
I have got a table in MS Access 2007 with 4 fields. Labour Cost

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.