2
I am on a project, where the front-end layer is totally, TOTALLY separate from the Banck-end. They communicate via ajax via REST.
And in this project, I’d like to break the html, so I don’t get duplicate content. Just as we do in Asp.net (master.pages and usercontrols), java, php, etc. For example creating a top/header and a footer q are always fixed on a template page, and the content of this only loads the content of other pages.
The big problem is that I need to do this using only HTML5 or at most Javascript. As far as my knowledge goes, that’s not very possible. I tried using html iframe, but it’s not very functional.
Does anyone have any idea, or reference to how to solve this?
Thanks in advance.
Some restriction on having, for example, a <Section> or a <article> with a defined ID and you load data with $.ajax and populate it with jquery.html()?
– Bruno Augusto
There’s no restriction @Brunoaugusto, there’s some reference to how I can do this?
– Erico Souza
The very manual of jQuery.ajax() has examples, although only one of them demonstrates the use of a selector when the request is completed, in done().
– Bruno Augusto
All right, I’m gonna take a look, and I hope this brings me a solution. The data I’m going to upload with $.ajax can be a piece of html code in a text file, right? For example menu.html
– Erico Souza
recommend the use of some libraries created for this purpose as the knockoujs Angularjs Backbonejs or Emberjs. They provide two-way bindings between html and backend data by javascript. In one of the tutorials of Knockoutjs he teaches to create a Singlepage Application (which is what I believe you seek)
– Caputo
Another thing, you can use Serverside Include and keep changing the visibility of the content, if the site is all static
– Caputo
@Caputo, the site is totally dynamic, but it has this total separation. From Java and HTML, it’s not something like jsf or jsp. This has complicated my life. I do not know Angularjs, I will research about and see if you meet me. For now I managed to do via ajax and is supplying my need.
– Erico Souza
@Ericosouza From home I put an example of use with Knockoutjs. It is also with Ajax, as in the example below, but has some features to make it easier to manage content
– Caputo