Proxying
Because of JavaScript's same origin policy a JavaScript program (such as JWChat) can only communicate with the hosting webserver. All traffic must therefore be proxied by the webserver to the XMPP server. A webserver such as Apache can be configured to act as a reverse proxy. An alternative to this relaying of traffic is to use a minimal webserver in the XMPP server such as the module included in ejabberd.
Read more about this topic: JWChat