[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 &lt;zer_matt at hotmail.com&gt; wrote:
<br>&gt;
<br>&gt; Thanks Eric!
<br>&gt;
<br>&gt; I'm not that JS guru I should be....  Could you please explain a bit more
<br>&gt; how this would work?
<br><br>Ok, try this (untested):
<br><br>var yourParameter = {&quot;some&quot;: &quot;thing&quot;};
<br><br>function yourCallback(parameter, request) {
<br>&nbsp; &nbsp; // &quot;parameter&quot; references the same object as &quot;yourParameter&quot; above
<br>&nbsp; &nbsp; console.log(parameter);
<br>}
<br><br>OpenLayers.Request.GET({
<br>&nbsp; &nbsp; url: yourUrl,
<br>&nbsp; &nbsp; callback: OpenLayers.Function.bind(yourCallback, null, yourParameter)
<br>});
<br><br>Alternatively, you could rely the scope (also untested):
<br><br>var yourParameter = {&quot;some&quot;: &quot;thing&quot;};
<br><br>function yourCallback(request) {
<br>&nbsp; &nbsp; // &quot;this&quot; references the same object as &quot;yourParameter&quot; above
<br>&nbsp; &nbsp; console.log(this);
<br>}
<br><br>OpenLayers.Request.GET({
<br>&nbsp; &nbsp; url: yourUrl,
<br>&nbsp; &nbsp; callback: yourCallback,
<br>&nbsp; &nbsp; 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