5
I have the following doubt:
When I make a request via AJAX
and I wish to "ride" the HTML
based on data from a banco
, is wrong (in terms of "good practice") to already return the HTML
in the request itself?
Or is it better (as I currently do) to return the data in JSON
and use a javascript template engine to process this data to the DOM
?
(example: underscore.js)
I’m asking this because I saw that the Facebook, in some requisitions XHR
, returns the HTML already in the request response itself. (and hence the question arises in the head: "If Facebook did, it is because it is right?")
I think this varies a lot from programmer to programmer and not much from good practices
– MarceloBoni
I never mind good practice, actually tag has been removed a few times and should even go to the blacklist. It has no meaning, even more misspelled. Good practice is to do what is right in that particular situation. Without knowing the specific situations any indication of "good practice" is wrong. And the biggest problem is that people interpret them as something to always do. In this case, who is not specific, I would say that you should traffic data. If there is any reason in your composition exist tags HTML, do.
– Maniero
I have my doubts if it can answer without incurring opinion, if there is any real reason to choose one or the other.
– Maniero
@Marcelo, The problem of "varying from programmer to programmer" is that you never have a pattern (this no
PHP
, Believe me, it’s a very big problem!)– Wallace Maxters
@Wallacemaxters, but this is unfortunately in all programming environments and etc... For example when programming a
CLP
,microprocessador
, vc tbm does not have a well defined pattern, its programming will depend on what the producers of thatCI
decided to adopt when assembling the architecture of the same... it goes from the lowest level of programming to the highest level– MarceloBoni
The only good practices I can think of are not using synchronously and not doing parse of the return with
eval
.– Vitor Canova
@Marcelobonifazio, so we can say roughly that the "design patterns" serve only to decrease the number of gambiarras? Because we really always have the problem of something being out of the standard (even if it’s not a design standard, but the standard applied to that specific application)
– Wallace Maxters
@Wallacemaxters "me" would say yes, it depends on the project, on your need, on the "good practices of your company".... but as @bigown said, it’s hard to answer
sem incorrer em opinião
, both in relation to good practice, and the very term of what comes to be good practice– MarceloBoni