Recently I've been working on embedded enquiry forms that Rentability users can place on their own website to take enquiries via their Rentability account. We wanted the person enquiring to remain on the owners homepage after submitting their enquiry (rather than be redirected to our site) so an AJAX submission was called for. Of course, when you try to make an ajax request from one domain to another (even if the code that is making the request came from the target domain), you find it doesn't work - most browsers veto the request for security reasons. The workaround is to use SCRIPT tags to emulate AJAX requests. Luckily, Thierry Schellenbach has written a plugin for Prototype to make Prototype AJAX requests use this SCRIPT tag technique.
Unfortunately, there are some major limitations here. For a start, you're obviously limited to using the GET method. In our case this is quite irritating as it's an "update" action that's being called (which is normally only accessible via a POST). Also, the request is going to be made with whatever request headers the browser decides to use. IE is typically braindead in this respect and will probably cause you pain if you have both JS and HTML responses for your action (as we do).
1 Objectextend Ajax Requestprototype 2 3 thisoptions = 4 method: 'post' 5 asynchronous: true 6 contentType: 'application/x-www-form-urlencoded' 7 encoding: 'UTF-8' 8 parameters: '' 9 evalJSON: true 10 evalJS: true 11 ; 12 Objectextendthisoptionsoptions || ; 13 14 thisoptionsmethod = thisoptionsmethodtoLowerCase; 15 16 if ObjectisStringthisoptionsparameters 17 thisoptionsparameters = thisoptionsparameters toQueryParams; 18 else if ObjectisHashthisoptionsparameters 19 thisoptionsparameters = thisoptionsparameters toObject; 20 21 thistransport = !thisoptionscrossSite ? Ajax getTransport : ; 22 thisoptionsasynchronous = !thisoptionscrossSite ? thisoptionsasynchronous : false; 23 //turns of the timed onLoad executer 24 thistransport respondToReadyState = thisrespondToReadyState bindthis; 25 thisrequest url; 26 27 ;