javascript - Is it good to return html code to jquery? -
i'm working on project has number of pages. each page displays 10 rows layout using each page different. until had html code of each row in javascript code , based on page's url using appropriate html code (if statement). if statement inside loop looping based on number of rows. results of rows coming ajax method. want somehow separate can more me maintain it, remove html code javascript , keep each row's html code different file.
note: ajax in given time, sending automatically requests php file new rows.
one solution came out can use php create variable html code .
second solution create array of each record html code , pass jquery print it.
both solutions don't know if solutions , can me maintain project in future.
you might consider template library such handlebars templating. frameworks such angularjs , ember excel @ solving these kinds of problems.
your web services api should returning json though, not html fragments. let client build dom, , let server focus on data.
Comments
Post a Comment