The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Trivial AJAX, encoding gotchas: comment previews

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
Trivial AJAX, encoding gotchas: comment previews Posted: Aug 6, 2006 6:47 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: Trivial AJAX, encoding gotchas: comment previews
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

Implementing inline comment previews is trickier than it seems, as trivial as the involved AJAX is. I took a look at a couple familiar blogs and saw that getting it right is relatively difficult.

Everybody's beloved redhanded (powered by hobix) can't swallow non-ASCII text: redhanded-broken.png

Typo seems to do the Right Thing, but I found at least one browser broken enough to mangle the preview (Konqueror 3.4.3, I don't know whether it's fixed in newer versions): typo-konq-bug.png

Problems

Implementing an inline preview pane sounds as easy as it gets, after all all you have to do is

  1. take the contents from a textarea and escape them appropriately
  2. send them to the server with an XMLHttpRequest and await the response with the formatted version (just some HTML)
  3. update the innerHTML attribute of some hidden DIV you had somewhere in the page and show it

Only three things to do, little room for errors, right? Well, it turns out there are also at least three potential problems when you're using GET for the request:

  • how to escape properly (client-side, Javascript)
  • returning a correct response (server-side, your-lang-of-choice)
  • having the preview displayed as it should

Escaping


Read more...

Read: Trivial AJAX, encoding gotchas: comment previews

Topic: rcov 0.7.0: code coverage and callsite/defsite data aggregation across multiple runs Previous Topic   Next Topic Topic: Yawn, another Ruby conference sells out

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use