Thursday, July 30, 2009

[jQuery] Cross-domain (for analytics)

I've run up against a cross-domain Ajax problem, essentially I want to
do something like:

(in http://hostA.com/page.html)

<script>
$.ajax({
type: "POST",
url: "http://hostB.com/service.php",
data: dataText,
...

but this promptly produces an [Exception... "Access to restricted URI
denied" code: "1012"...

The thing is, unlike most of the related scenarios I've found, I don't
actually want anything back from the server, I just want to send off
some page access data.

Because ultimately I want this thing to be easy for end-users, the use
of a server-side proxy is something I'd like to avoid. I'm pretty sure
this should be doable /somehow/ - it appears that Google Analytics
must get around the problem, but I haven't been able to suss out how.

Suggestions?

(the code I'm working on is linked from http://hyperdata.org/wiki/wiki/TtrackerHowItWorks
)

Cheers,
Danny.

No comments: