[OpenLayers-Users] Passing parameters to ajax request callback
method
Eric Lemoine
eric.c2c at gmail.com
Tue Mar 17 04:29:30 EDT 2009
On Mon, Mar 16, 2009 at 10:30 PM, Zer <zer_matt at hotmail.com> wrote:
>
> Thanks Eric!
>
> I'm not that JS guru I should be.... Could you please explain a bit more
> how this would work?
Ok, try this (untested):
var yourParameter = {"some": "thing"};
function yourCallback(parameter, request) {
// "parameter" references the same object as "yourParameter" above
console.log(parameter);
}
OpenLayers.Request.GET({
url: yourUrl,
callback: OpenLayers.Function.bind(yourCallback, null, yourParameter)
});
Alternatively, you could rely the scope (also untested):
var yourParameter = {"some": "thing"};
function yourCallback(request) {
// "this" references the same object as "yourParameter" above
console.log(this);
}
OpenLayers.Request.GET({
url: yourUrl,
callback: yourCallback,
scope: yourParameter
});
Cheers,
--
Eric
More information about the Users
mailing list