views:

651

answers:

2

This is more of a conceptual question.

I'm trying to create a Javascript jabber client that can be installed on any arbitrary page (on x.com and y.com), and I'd like this client to be able to communicate with a remote jabber server (chatserver.com).

According to the readme of one javascript client I'm lookign at (jsjac), it is an inherent limitation of javascript that it can't communicate with a remote server due to cross site issues.

I'd appreciate hearing from anyone about how to overcome this hurdle. A pointer to an example would be extremely helpful.

[Update] I'm assuming here that I have no control over x.com and y.com, the client servers. The folks at Hab.la seem to have pulled this off, not sure how.

A: 

The simplest way around this is to proxy the requests from the JavaScript client to the remote server, via the server that hosts the client.

Apache's mod_proxy extension handles this fine.

Jon Benedicto
Thanks Jon. What if I don't control the client server (i.e. the chat widget is a javascript that can be inserted by anyone). The folks at Hab.la seem to have pulled it off, not sure how they did.
Perhaps they're using dynamically generated script tags, or an IFRAME, both of which methods can be used to contact different hosts.
Jon Benedicto
A: 

Hey,

Look at flXHR (search for it as I am not allowed to submit links) seems like a simple and elegant solution