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

  • SEARCH
  • Home
  • 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 3635974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:58:18+00:00 2026-05-19T00:58:18+00:00

I want to make a few divs on the same page work similar to

  • 0

I want to make a few divs on the same page work similar to iframes. Each will load a URL which contains links. When you click on those links I want an AJAX request to go out and replace the div’s html with new html from the page of the clicked link. It will be very similar to surfing a page inside an iframe.

Here is my code to initially load the divs (this code works):

onload:

$.ajax({
  url: "http://www.foo.com/videos.php",
  cache: false,
  success: function(html){
    $("#HowToVideos").replaceWith(html);
  }
});
$.ajax({
  url: "http://www.foo.com/projects.php",
  cache: false,
  success: function(html){
    $("#HowToProjects").replaceWith(html);
  }
});

This is a sample of code that I’m not quite sure how to implement but explains the concept. Could I get some help with some selectors(surround in ?’s) and or let me know what is the correct way of doing this? I also want to display a loading icon, which I need to know where the right place to place the function is.

$(".ajaxarea a").click(function(){
        var linksURL = this.href; // 
        var ParentingAjaxArea = $(this).closest(".ajaxarea");;
        $.ajax({
      url: linksURL,
      cache: false,
      success: function(html){
        $(ParentingAjaxArea).replaceWith(html);
      }
    });
    return false;
});

$(".ajaxarea").ajaxStart(function(){
    // show loading icon
});
  • 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-19T00:58:19+00:00Added an answer on May 19, 2026 at 12:58 am

    Figured it out! The problem was I was using the function “.replacewith()” which was removing my AJAXed div(class=”ajaxarea”) entirely instead of replacing the content. The proper function to use here was “.html()”.

    Here is my working code to make an AJAXed div work like an iframe:

    //onload to initialize the div
    $.ajax({
      url: "http://www.foo.com/projects.php",
      cache: false,
      success: function(html){
        $('#HowToProjects').html(html);
      }
    });
    
    $(".ajaxarea a").live('click',function(e){ // must use live instead of .click()
      e.preventDefault();
      var URL = $(this).attr('href');
      var parentFrame = $(this).closest(".ajaxarea");
      $.ajax({
        url: URL,
        cache: false,
        success: function(html){
          parentFrame.html(html);
        }
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got in Library few MovieClips and I want to make function which is
I want to make few paramters optional using regular expression currently my url is
I want to make my own function which performs in a similar manner to
Lets say I want to make few classes to determine behaviour of agents. The
I want to make some modifications to a few selected tick labels in a
I'm building a few SharePoint sites, and I want to make use of zones
I want make a bash script which returns the position of an element from
I want to make a few customizations to jQuery UI Autcomplete: 1) If there
I want to make a class that creates an element with a few properties
I want to make a site, and I've learned a few languages, but I

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.