[Greasemonkey] GM_xmlHttpRequest question

Anthony Lieuallen arantius at gmail.com
Fri Jul 28 17:28:30 EDT 2006


On 7/28/2006 4:20 PM, Jossie Mann wrote:
> ...  My problem is, how can I store the association between the html
> tag and the xmlHttpRequest so that when the xmlHttpRequest returns
> back to the page I know which html tag triggered it.

Your answer is closures:
http://en.wikipedia.org/wiki/Closure_(computer_science)
http://jibbering.com/faq/faq_notes/closures.html

In pseudocode:

for (elements) {
	function() {
		el=elements[i];
		xhr_start(callback=xhr_call);
	}
}

function xhr_call() {
	el.innerHTML=response.responseText;
}


More information about the Greasemonkey mailing list