jquery - Load HTML with Ajax vs. load only data with Ajax and build the html with Javascript -
i'm working on project needs load via ajax
html
information on page.but i'm not quite sure how load information.
i don't know method better me:
1) load entire html
ajax
, append page
or
2) load data ajax
, build html
using javascript
(+jquery
)
the 1 tend use first method because it's easiest 1 more expensive regarding memory
(the biggest file have load has 7kb
not much)
the second one hardest, involves huge javascript
(jquery
) code build html
(i have load attributes element).and because have lots of different html
code load have make lots of conditions
(e.g. 1 button
, 1 title
, 1 textarea
etc) , have create variables
containes html
.
my question method best use in case?
i stick solution cleanly divide data/logic , view. case in first alternative. making changes html generated javascript quite hard.
i'd suggest option: use client side templates. load template , data ajax call , fill out template using javascript. there libraries out there scenario.
Comments
Post a Comment