07/23/08
Javascript Cross Domain Ajax
Originally as more of a low level technologist who only picked up ajax and interface development as a smooth view state for communicating with my middle tier controllers I found Javascript to be very much lacking the web services department. Very often the techniques that have been traditionally used consist of one of two strategies for x-domain communication;
1- A remote javascript include is served using:
javascripthover edges to scroll
<script type='text/javascript href='http://remotehost/js/api.js?param=1¶m2'>
2- By matter of Proxy.
This method I’ve used very often for direct communication with XML, SOAP, or REST gateways. Generally, I will develop the interface layer to communicate with a server side controller which will then use Curl to invoke the remote data, process and return as an JSON object. I find this method to be very robust, and allows you to create a very extensible gateway for your Javascript cross domain requests.
With that said, the post I read this morning is indicating that a new methodology for cross-domain scripting is emerging in the Dojo framework. By way of the property window.name one can make a remote request and retrieve data without exploiting the ever so wonderful cross domain security model that we are subject to in all our favorite browsers. This concept is very new but interesting. It opens up a whole new world of client side mash-up possibilities that are sure to get the creative juices flowing in the client side development space. Here is an example of it would be implemented:
javascripthover edges to scroll
dojox.io.windowName.send(method, args); // simple method
// deferred result
var deferred = dojox.io.windowName.send("GET", {url:"http://somesite.com/resource"});
deferred.addCallback(function(result){
alert("The request returned " + result);
});


































No comments yet.