Reputation: 3917
I have 2 HTML Files.
these 2 HTML files will make be needed to added.
Is there a way in Javascript, Jquery that I can add 2 files and get a single file.
In Jquery I saw append and other functions but my usecase is I want to add 2 Big files
Upvotes: 0
Views: 237
Reputation: 5131
I don't have the exact code but you shouldn't need it (jQuery well documented)
Although, this type of thing sounds better for a server side language like PHP. You can make an ajax request for the "builder" PHP file, which will return the two files put together. Plus, if you use templates right, you won't need to do the head/body filtering messy stuff
Example pseudocode
//template.php
<html>
<head></head>
<body>
<?php include 'foo.php'; ?>
</body>
</html>
//foo.php
My html content
<h1>Hello</h1>
//bar.php
My other page
<h1>About</h1>
//builder.php
<html>
<head></head>
<body>
<?php include 'foo.php'; include 'bar.php'; ?>
</body>
</html>
Not the best example (very, very simple) but it should give you the idea. Get an ajax request on builder.php, and that's all your content. You could make it even more powerful by creating a builder.php file that takes filename parameters to concatenate (and you should do validation on these files...)
Upvotes: 1