[Greasemonkey] A question about GM_xmlhttpRequest

Rick Evans EvR at sfcn.org
Thu Feb 9 17:29:15 EST 2006


Given the following Greasemonkey script:

// ==UserScript==
// @name           test of GM_xmlhttpRequest
// @namespace      http://mywebsite.com/myscripts
// @description    A template for creating new user scripts from
// @include        *
// ==/UserScript==

  alert( 'message 1' );
  GM_xmlhttpRequest(
    {
      method:'GET',
      url:'http://greasemonkey.mozdev.org/',
      onload:function(details) {
        alert( 'message 2' );
      }
    }
  );
  alert( 'message 3' );

The alert messages come in the following order:

message 1
message 3
message 2

Is there a way to modify the behavior of the GM_xmlhttpRequest so that the
onload function must finish and alert 'message 2' execute before the script
continues with the 3rd alert message?

Thanks for any insight you can provide.

Rick



More information about the Greasemonkey mailing list