Facebook uses a Comet and JSON approach to receive incoming messages. Comet is a technique where you open a long running HTTP connection to a server (usually AJAX).
Coding Library:
Javascript/AJAX
More Facebook Platform Resources:

