[Greasemonkey] XMLRequest

Edward Kawas edward.kawas at gmail.com
Tue Aug 1 13:13:03 EDT 2006


Hi,

I am sure that this question has been asked before, but I can't find any
answers.

I am trying to do something along the lines of the following:

GM_xmlhttpRequest({
		method: 'POST',
		url: 'http://localhost/someURL,
		headers: {
			'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey'
		},
		onload: function(responseDetails) {
			GM_log('Done ' + responseDetails.status);
			if (responseDetails.status == 200 ||
responseDetails.status == 202) {
				// do stuff with response
			} else {
				// do some error stuff
			}
		}, 
		onerror: function(responseDetails) {
			GM_log('onerror');
			// do some error stuff
		}, 
		onreadystatechange: function(responseDetails) {
			GM_log('on ready state change ' +
responseDetails.readyState);
			if (responseDetails.readyState < 4) {
				// tell user that we are still trying to get the
request
			}
		}
});

Basically, I am trying to just let the user that something is expected to
happen, but we are waiting. Doing the above only logs:

http://localhost/monkey monkey: on ready state change 1
http://localhost/monkey monkey: on ready state change 1
http://localhost/monkey monkey: on ready state change 2

And stops there. Even if I wait 10 minutes or more.

Am I not understanding the logic for these callbacks?

Thanks,

Eddie



More information about the Greasemonkey mailing list