This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Clean up script Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Clean up script" Watch "Clean up script" New topic
Author

Clean up script

Todd Smith
Greenhorn

Joined: Dec 16, 2010
Posts: 25
I want to clean up my code. I am getting a JSON Object returned from my spring controller and I am display it using the Jquery .append method. It looks very messy. Should I be using jQuery Template Markup Language (JTML) to clean it up. Please advise



[Edit: modified subject as this has nothing to do with JSP]
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

So a couple of things:

1. If you're going to use jQuery, use jQuery


2. I'm still doing some testing to determine the merits of jQuery Template API over letting the server do it. In your case, I might just use jQuery's load() function. Let the server generate your HTML and just plop that rendered HTML into a container using load().
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
Way too many appends.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56221
    
  13

Like Gregg, I'm a big fan of letting the server do the work. I prefer to deliver pre-formated HTML fragments (templated using JSP or other server-side templating) over client-side DOM manipulation or templating. I use the client-side mechanisms only when it makes more sense than doing it on the server.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Clean up script
 
Similar Threads
Displaying an inline error message in a JSP
struts-2 (set values to action class)
Calling a new JSP form a Spring Controller using Ajax
problem in reset() function
problem with jsp for reset() method