Disadvantages of HTML injection?
-
Hi. I´ve created several web pages, that makes use of HTML injection. That means a script on a web page that calls a web service, gets html code returned, and the script then injects the html code in a div somewhere. This solution avoids postbacks, returns data faster back to the end-user and creates a more smooth web experience. But what are the downsides of html injection? The only thing I can think of, is that code maintainance gets harder as the project gets larger.. Thanks for your thoughts. Kind regards, Lars
-
Hi. I´ve created several web pages, that makes use of HTML injection. That means a script on a web page that calls a web service, gets html code returned, and the script then injects the html code in a div somewhere. This solution avoids postbacks, returns data faster back to the end-user and creates a more smooth web experience. But what are the downsides of html injection? The only thing I can think of, is that code maintainance gets harder as the project gets larger.. Thanks for your thoughts. Kind regards, Lars
lvq684 wrote:
script on a web page that calls a web service, gets html code returned
Actually that is the only part I don't agree with. The webservice should indeed not return HTML but rather raw (JSON) data. Encapsulate the javascript that generates the HTML (from your data) into sparate classes, that way you keep your webservices uncontaminated from GUI/UI stuff. The code for the HTML generation can be reused and maintained separately. My two cents. Cheers,
-
lvq684 wrote:
script on a web page that calls a web service, gets html code returned
Actually that is the only part I don't agree with. The webservice should indeed not return HTML but rather raw (JSON) data. Encapsulate the javascript that generates the HTML (from your data) into sparate classes, that way you keep your webservices uncontaminated from GUI/UI stuff. The code for the HTML generation can be reused and maintained separately. My two cents. Cheers,
-
Anytime! :)
-
lvq684 wrote:
script on a web page that calls a web service, gets html code returned
Actually that is the only part I don't agree with. The webservice should indeed not return HTML but rather raw (JSON) data. Encapsulate the javascript that generates the HTML (from your data) into sparate classes, that way you keep your webservices uncontaminated from GUI/UI stuff. The code for the HTML generation can be reused and maintained separately. My two cents. Cheers,
Good answer..