S
S
serjio2012-02-10 08:58:16
JavaScript
serjio, 2012-02-10 08:58:16

Is there an analogue of include through java-script (you need a local insertion of one piece of html into another)?

I'm laying out large pages, it would be convenient to divide them into pieces and call smaller pieces in the main html using js, is this possible?
(The suggestion to run a local php project does not work)

Answer the question

In order to leave comments, you need to log in

7 answer(s)
X
xmoonlight, 2019-11-05
@serjio

includeHTML

S
Sergey Cherepanov, 2012-02-10
@fear86

api.jquery.com/jQuery.get - there, even in the examples, the code for loading html and inserting it into a block.

I
IonianWind, 2012-02-10
@IonianWind

If the server is under Apache, then SSI will help: httpd.apache.org/docs/current/howto/ssi.html

S
Sergey Cherepanov, 2012-02-10
@fear86

What would work without a server is better to do something like this:


You just need to modify it with a file.
In the days before Ajax, this is how Ajax support was implemented in older browsers, and in the same way, sending files still works in most modern browsers.

S
Sergey Cherepanov, 2012-02-10
@fear86

Well, just execute an Ajax request to the desired piece, and then insert it into the page?
But all this will slow down the page loading a little, if not critical, then any js framework will do this with two lines of code.

S
serjio, 2012-02-10
@serjio

the trick is that without a server and as simple as possible, the solution has already been found (see above)

F
fishbone, 2012-02-10
@fishbone

There is. I googled a bit here for you, here is www.boutell.com/newfaq/creating/include.html. Client-Side Includes section.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question