[OpenLayers-Dev] asynchronous cross domain POST request inside openlayers

loic devaux devloic at gmail.com
Tue Mar 31 11:30:56 EDT 2009


Hi List,

I am implementing a new OpenLayers layer type ( using existing WMS layer code) to display data from CartoWeb (3.5) Web-GIS with OpenLayers. Because CartoWeb's architecture can be divided in two servers ( one dealing with the user interface and another dealing with the GIS processes) I need to make a cross browser POST request to fetch data but that's not possible with Xmlhttprequest . I don't want to user OpenLayers Proxyhost capability because that will increase traffic and complexity for deployment.
There are some solutions with GET requests but the one that works fine for me for POST requests is submitting a dynamically generated form inside a dynamic iframe. I read Google Maps has something similar.
Now my problem is that I rely on the onLoad event of the iframe that tells me when the fetched data is available in the browser. Because this is an asynchronous execution I haven't found a way to feed OpenLayers with the data because there is no way (?) in javascript ( without doing ugly cpu intensive javascript loops or waiting for javascript 1.7 ) to halt execution and resume it once the callback function (which retrieves the data) associated to the onLoad event of my iframe has been triggered. 
I managed however to make things work for the layerswitcher control but the other openlayers controls are far more complex and  I try to be the less intrusive as possible so I don't want to modify the source code of each control (which wouldn't be a solution for custom controls anyway).
The only solution I see would be to be able to specify the execution order of the callbacks so I could execute my callback first which woud :
- store the event context
- stop the other callbacks from executing 
- fetch the CartoWeb data
- recall the stopped callbacks using the stored context 

I don't know if this is feasible as it seems that each browser might handle the execution order of browser events differently but maybe OpenLayers has more control on his own events.

Sorry for the necessary verbosity. I'd be glad to see alternative solutions. I believe that by solving this problem we would at the same time extend OpenLayers interoperability since cross domain requests inside the browser might more and more belong to the future of the web even though this raises legitimate security concerns.

Loïc
-- 
View this message in context: http://n2.nabble.com/asynchronous-cross-domain-POST-request-inside-openlayers-tp2563656p2563656.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list