Added on: Thursday 14th January 2010
I was recently working on an ajax script to update our CMS shopping cart and noticed some strange behaviour.
The html for the cart is stored as an editable template to allow it to be styled for different sites. The currency symbols are written into the template.
When the page was first loaded the PHP script processed the template and displayed everything just fine. However, when the cart was updated via the ajax script the currency symbols were replaced in Firefox by the FF FD code for a missing character in a font.
I thought at first that by using the javascript escape function to encode the characters or by using html entity encoding in PHP it would solve the problem. Unfortunately, both of these didn't work.
A quick Google search and I found this article on Roshan's Blog.
The solution is to set the character set in the script that outputs the html to the ajax function using the PHP header function (example below).
header("Content-Type: text/html; charset=iso-8859-1\n");
Andrew Parrott runs Round Ash Associates, a web design and development company based in Chagford on Dartmoor, Devon.
If you prefer updates via email then please enter your email address below and click Submit.
If you haven't been to Chagford before then take a look a what you are missing.
Sitepoint is an indespensible resource for web designers.
Internet Explorer isn't the only web browser and from a development point of view Firefox is much better.
As many of the articles on this site are slightly techy I thought I ought to link to a glossary of Internet terms.
The layout for this site uses one of Matthew James Taylors 'liquid layouts'.
©Round Ash Associates 2009. Powered by form2list.