Load content from an url in an element (without jQuery)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Mirko Brombin 0d05da08af Do not append content_process to body 1 month ago
LICENSE Create LICENSE 4 months ago
README.md Update README.md 4 months ago
httploader.js Do not append content_process to body 1 month ago

README.md

httploader.js

Load content from an url in an element (without jQuery)

How to use

First of all import httploader.js in your project.

Assuming we have a data.html page:

<ul>
  <li>Hello</li>
  <li>World</li>
</ul>

and index.html:

<html>
  <body>
    <h1>Words</h1>
    <div id="data"></div>
  </body>
</html>

we want to load data inside the #data element, so:

var data = document.getElementById("data");
load(data, "data.html");

This will put the content of data.html into # data.

Load portion of source

Let's say we have a data.html like the following:

<html>
  <body>
    <ul>
      <li>Hello</li>
      <li>World</li>
    </ul>
  </body>
</html>

we want to load only the ul inside our #data element. We are going to do this:

var data = document.getElementById("data");
load(data, "data.html", "body>ul");

That's all Folks.