Javascript, HTML, XML, PHP

JS, HTML, XML, PHP, AJAX, CSS - things we all know for building Web-UIs. Though there are thousends of manuals out there, i wanted to take some notes...

I wondered, why we use 6 languages for one page, but it makes sense if you categorize it.

  • Server scripting - PHP
  • Content, Data - HTML/XML
  • Client scripting, User Interactivity - JS
  • Look - CSS

Although others don’t do it my way, I always obey some rules on AJAX-applications:

  1. show the user if somethings happening in the background (a loading gif)
  2. Javascript disabled must not break the application. This means i implement all the basic features in (X)HTML and then add some AJAX features that are optional.
  3. Browser interoperability: I don’t check for browser. I use features that work on all browsers (this really works!)

I’m not a fan of frameworks (like DOJO), that do all the work for you. It’s because I’m a minimalist and I like to know where my stack pointer is. So I either read the complete framework to understand it or I build just what I need on my own.


AJAX and IE

You can find this problem at the Javascript group in comp.lang with the name “Microsoft.XMLHTTP problem”:

And I found a solution.

The symptoms

The line

result = http_request.responseText;

or any code containing http_request.responseText crashes with the message: (in a german Internet Explorer)

Systemfehler: -1072896658

meaning:

system error: -1072896658

The problem

The encoding utf8 was set.

You might now think: “UTF8? This is generally considered good! What’s wrong with that.” the dash. It’s utf-8 and not utf8. Never write utf8. IE only knows utf-8.

The Solution

Replace the encoding of

utf-8

with

utf8

WRONG:

header("Content-Type: text/html; charset=utf8");

CORRECT:

header("Content-Type: text/html; charset=utf-8");

And this site looks funny in Deer Park Alpha 2 trunk nightly 20060329 :D

Vietnam Railways