[OpenLayers-Users] Passing parameters to ajax request callback
method
Zer
zer_matt at hotmail.com
Mon Mar 23 15:14:26 EDT 2009
Thanks Eric!
<br><br>I tried your first example, and that did the thing! Thank you, thank you!
<br><br>Z
<br><br><blockquote class="quote light-black dark-border-color"><div class="quote light-border-color">
<div class="quote-author" style="font-weight: bold;">Eric Lemoine wrote:</div>
<div class="quote-message shrinkable-quote">On Mon, Mar 16, 2009 at 10:30 PM, Zer <zer_matt at hotmail.com> wrote:
<br>>
<br>> Thanks Eric!
<br>>
<br>> I'm not that JS guru I should be.... Could you please explain a bit more
<br>> how this would work?
<br><br>Ok, try this (untested):
<br><br>var yourParameter = {"some": "thing"};
<br><br>function yourCallback(parameter, request) {
<br> // "parameter" references the same object as "yourParameter" above
<br> console.log(parameter);
<br>}
<br><br>OpenLayers.Request.GET({
<br> url: yourUrl,
<br> callback: OpenLayers.Function.bind(yourCallback, null, yourParameter)
<br>});
<br><br>Alternatively, you could rely the scope (also untested):
<br><br>var yourParameter = {"some": "thing"};
<br><br>function yourCallback(request) {
<br> // "this" references the same object as "yourParameter" above
<br> console.log(this);
<br>}
<br><br>OpenLayers.Request.GET({
<br> url: yourUrl,
<br> callback: yourCallback,
<br> scope: yourParameter
<br>});
<br><br>Cheers,
<br><br><br>--
<br>Eric
<br>_______________________________________________
<br>Users mailing list
<br>Users at openlayers.org
<br><a href="http://openlayers.org/mailman/listinfo/users" target="_top" rel="nofollow">http://openlayers.org/mailman/listinfo/users</a></div>
</div></blockquote>
--
View this message in context: http://n2.nabble.com/Passing-parameters-to-ajax-request-callback-method-tp2487503p2522929.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list