0

Am trying to include html file in another html file and then alert result.

I found a solution here.

Source Please how do I alert the content of b.html instead of calling it in div.
something like

alert('b.html content here');

a.html:

<html> 
  <head> 
    <script src="jquery.js"></script> 
    <script> 
    $(function(){
      $("#includedContent").load("b.html"); 
alert('b.html content here');
    });
    </script> 
  </head> 

  <body> 
     <div id="includedContent"></div>
  </body> 
</html>

b.html:

<p>This is my include file</p>
Nancy Moore
  • 2,322
  • 2
  • 21
  • 38

1 Answers1

0

jQuery has a handy function for getting other webpages, $.get():

$.get('b.html', function(data) {
    alert(data);
});

function(data) {} is a callback which runs when the http request is made successfully, and data will contain the response body.

Joundill
  • 6,828
  • 12
  • 36
  • 50