On Tue, Oct 21, 2008 at 1:41 PM, Jérome Freyre <[EMAIL PROTECTED]> wrote:
> [...] > > Based on the example > (http://openlayers.org/dev/examples/protocol-gears.html), I create a method > called sync : > > function sync() { > resp = view.protocol.read(); > if (!resp.success()) { > alert("reading failed"); > return; > } > > view.destroyFeatures(); > > if (!resp.features || resp.features.length <= 0) { > alert("No features to read"); > return; > } > view.addFeatures(resp.features); > alert("features successfully read"); > } > > view.protocol.read() is correctly working (I saw the call to getGeoJSON in > firebug) and my getGeoJSON.php return the correct GeoJSON. But my function > always do the alert on the "reading failed" and I don't understand why!? Because, as opposed to Protocol.Gears, Protocol.HTTP is asynchronous. You need to pass a callback to read() and read the response from there: protocol.read({ callback: function(resp) { if (!resp.success()) { alter("failure"); } } }); -- Eric _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
