Question

I need to return a list of blog posts (subject, body, datecreated, commentCount)

Should I return a json response or xml?

In the calling page, I will have to inject this into the page (its an ajax call).

So I need to be able to loop through the blog posts, and create HTML with the blog post info etc. and inject into the page.

I'll be using jquery.

Was it helpful?

Solution

A JSON object is native Javascript, definitely recommended for client-side efficiency. Use the latest version of JQuery for secure JSON loading. Jquery is easy with $.each() to loop through JSON data and append it to page elements. Hope that helps!

OTHER TIPS

If you're going to be using this in client side javascript, then definitely don't use xml -- json is probably the way to go.

One other option to consider is to just bring down the formatted HTML. Personally, I'd go with the json and build the HTML client side, but doing that server side would be a non-crazy solution too.

json in combination with jTemplates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top