Hello
Hope somebody can help real quick to confirm that this is the way to
do it:

I've an AJAX request that is supposed to update some fields
onComplete.

this is the code I have:

getdata:function() {
                        // fetch geodata and update form fields
                        this.chain (
                                function() {
                                        this.fetchGeodata(new GLatLng(lat, 
lng));
                                }.bind(this),
                                function() {
                                        var geodata = this.geodata;
                                        $('txtAlt').set('value', geodata.alt);
                                        $('txtTitle').set('value', 
geodata.name);
                                }
                        );
                        this.callChain();
}


the onComplete method of the ajax request issues this.callChain then
for the 2nd time.

fetchGeodata: function(latlng) {
                        if (!latlng) return false;
                        var request = new Request({
                                url: './scripts/requestGeodata.php',
                                autoCancel: true,
                                onSuccess: function(responseText, responseXML) {

                                        this.geodata = 
JSON.decode(responseText);
                                        this.callChain();

                                }.bind(this)
                        }).send({ lat: latlng.y, lng: latlng.x, mod: 'json' });
                },



It seems to work but I don't know if this is the way to do it.

Reply via email to