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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:13:25+00:00 2026-06-01T09:13:25+00:00

I have an iframe container inside the body section and a button. Any click

  • 0

I have an iframe container inside the body section and a button.
Any click upon the button makes a call to server and fetches some html content.
Now I want the html content which comes as response from my server to be placed inside the iframe. Here is the code I am doing:-

var url = 'http://www.google.com';
    var request = new XMLHttpRequest();
    var serverURL = "http://localhost:8080/myServer/getPage.htm";
    request.open('GET', serverURL + '?url=' + url, false);
    request.send(null);
    if(request.status == 200) {
        console.log(request.responseText);
        var resp = eval('(' + request.responseText + ')');
        var data = resp[0].data;
        //alert(data);
        var path = 'http://localhost:8080/test/about.html';
        $("#newPage").attr('src',data);
    }

On alerting data variable it is giving me correct html code but the last line is not working. I don’t know where i am doing wrong. For testing purpose I placed path instead of data then it worked perfectly. Please help!

  • 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-01T09:13:26+00:00Added an answer on June 1, 2026 at 9:13 am

    I think there is difference between string (javascript variable data here) and an actual html page. You might need to save your data variable in some html page and then update your iframe. I am not too sure about my solution. Check this out How do I dynamically change the content in an iframe using jquery?

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

Sidebar

Related Questions

i have iframe inside a page, and this iframe contain a submit button which
I have an IFrame app, and I would like to use some Connect features
I have an HTML file that contain iframe, say (called a.html): <body> <iframe width=430
I have a form inside an iframe which is inside a jQuery UI dialog
I have a div that is contain inside an iframe from a external html
I have PageA and PageB... PageA contains an iFrame and pageB is inside that
I have a form inside an iframe that needs to be manipulated from the
I have a div container with class embed and unique id. Inside the container
i need some help here. I have a dialog box that contains an iFrame
I have one entire html openning inside an iframe that contains a javascript function

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.