What type of data should an Ajax call return?
6 Comments

This is a good post on The Ajax Response, discussing if it should be XML, HTML, or JSON. I personally think under no circumstances should it be HTML, or anything that includes markup. That violates the principle of separating the content from the style and it prevents reuse, by yourself and others.

I think deciding between JSON and XML is going to depend on your situation. XML is much more universal. With XML, you can create Web Services from your back end, and call them for display in PHP, JSP, and with Ajax. That Ajax call you are making today maybe a non-Ajax call you make later.

Google Suggest is a prime example of silliness. That data response is completely unusable in any other scenario. Perhaps, knowing Google, they have done this on purpose to prevent others from using that feed as freely, but it could be a handy service to offer and implement in other locations. The way Google has chosen to implement it, would require Google to have many versions of that response, for multiple uses.

With the rare exception, when you serve up data from your back end, think in big picture terms of making that data available to all your front end applications, and then apply style (HTML, CSS, etc) to it, once the data is in the front end.

UPDATE: Ignore my reservations about HTML in AJAX responses and see my followup post: AJAX Returning HTML (change of opinion).

CSS3: Rounded corners and shadows
4 Comments

These CSS3 tips will certainly come in handy and will thankfully eliminate all those corner gif’s that I see so many websites using to get this effect.

Centering with CSS
Be the 1st to comment!

I found this helpful for centering some links today. It could be used to center any block on a web page, both vertically and horizontally.

JSPs with HTML extension
Be the 1st to comment!

Currently my hirebrianburridge.com web site is hosted without JSP functionality. However, I’ve written the entire web site in JSP and XML, so that I can simply edit two xml documents (one for the presentation at the beginning and one for the the main resume site). But since I can’t run those JSPs on my web site, I run them locally, and save all the pages (I use an app that does it for me) and ftp them to my hosted site. The only trouble is that I have to alter the links from having the .jsp extensions, and in some cases there is one jsp that takes a page name and produces the content. That link looks like this: index.jsp?slide=pagename. So that’s a lot of editing I have to do to the static html files before ftp’ing them to the live site.

So tonight I looked to see if I could make the .html extension run jsp pages, so that all my links would be correct without having to modify them. I found this helpful Filter which does exactly that. The filter looks at the URL requested, for example index.html, and translates it to index.jsp. I renamed all of my jsps on my local server to the html extension, and now when I run them to get static versions all the links work.

Page 2 of 2«12