GM_xmlhttpRequest problem

89 views
Skip to first unread message

Yeramihi

unread,
Sep 20, 2009, 12:17:45 PM9/20/09
to greasemonkey-users
Hi all.

here's my sample code:
------------------------
var container; // global variable;

GM_xmlhttpRequest({ method: 'GET', url: 'http://wikipedia.org',
onload: function (source) { container = source.responseText; }});

alert(container);
----------------------

As you probably know alert shows empty dialog, not code of wikipedia
page. I have long script which will use several GM_xmlhttpRequests and
for some reasons I cannot include my code within callback 'onload'
function, it has to be passed over to the 'parent' code. How can I
postpone greasemonkey to execute next line of code (in example: alert
command) until callback function will finish? Is it possible at all?

Cheers,


ryanemmm

unread,
Oct 2, 2009, 2:35:27 PM10/2/09
to greasemonkey-users
put the alert inside the callback

onload: function(source){
container = source.responseText;
alert(container);
Reply all
Reply to author
Forward
0 new messages