degath degath - 1 year ago 81
Ajax Question

from one html file to another in loop html/jquery/js/ajax

maybe its easy, but I'm really beginner in front end.
Right now I've got:

  • 1 main html file(index.html)

  • 1 javascript file(something.js)

  • 2nd html file(something.html)

Main html:

<!DOCTYPE html>
<html lang="en">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/something.js"></script>
<div class="container-fluid well-lg">
<div id="targetInformation">


2nd html:

<div class=" col-md-4 col-sm-6 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Some title
<div class="panel-body">

I want to:
create a loop in js/jquery/ajax to load 6 times what is inside 2nd html to a first html.
One thing I know is that I need to use $.get().
Any ideas how my js should look like, and how to use js in a div?
Thanks :)
Tried to find a solution, but didnt found, sorry for bothering

ps. I didnt send you my something.js, because its empty, really got no idea how to start.

Answer Source

Try This -

$(function () {
            $.get("something.html", function (data) {
              for(let i =0; i<6; i++)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download