I thought it was worth a quick post before I call it a night. Lately as I converse with colleagues who are getting more and more into the whole "Web 2.0" thing and therefore using more AJAX and JSON, I notice I'm sometimes the only one in the circle who recalls the awesome ColdFusion function JSStringFormat.
With this function you can take any amount of content and make it JavaScript friendly - you know, escaping single quotes and all that jazz. Even better is when you couple it with the cfsavecontent tag. Check this out, it's how I make a no-flash display.
<cfsavecontent variable="foo">This is some markup, can contain tons and tons of tags, even other script, etc.</cfsavecontent>
<cfoutput>
<script language="text/javascript">
var foo = '#JSStringFormat(foo)#';
</script>
</cfoutput>
Recent Comments