Include another HTML file in a HTML file Single Page Application
-
21-12-2019 - |
Question
I have small requirement that i want to include productresults.html file in productsearch.html in durandal(Single Page Application). Can any one help me on this and i have tried the following ways also.
<link rel="components" href="productResults.html">
<!--#include virtual="productSearch.html" -->
Thanks,
shiva
Solution 2
Thanks for your support and information.
Finally the code snippts works fine for me in SPA.
<!--ko compose: {view: 'nav'} -->
<!--/ko-->
OTHER TIPS
Solution using jQuery:
<html>
<head>
<script src="jquery.js"></script>
<script>
$(function(){
$("#includedContent").load("productResults.html");
});
</script>
</head>
<body>
<div id="includedContent"></div>
</body>
</html>
Hope this helps.
What you're trying to do is a Server side include.
Your web server must be configured to support it - it sounds like maybe your server isn't?
It's also possible your web server might require the file to have a special suffix, e.g. "productSearch.shtml".
You can look here for more details:
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow