This is my GM_xmlhttpRequest script:
// ==UserScript==
// @name test
// @namespace test
// @include http://stackoverflow.com/*
// @version 1
// ==/UserScript==
GM_xmlhttpRequest({
method: "GET",
url: "http://example.com",
onload: function(response) {
alert(response.responseText);
}
});
function begin(){
alert("ready");
}
$(document).ready(function() {
begin();
});
Which alerts only the contents of example.com, not "ready".
BUT when I do the following nothing happens - there are no alerts whatsoever:
function begin(){
GM_xmlhttpRequest({
method: "GET",
url: "http://example.com",
onload: function(response) {
alert(response.responseText);
}
});
alert("ready");
}
$(document).ready(function() {
begin();
});
What am I doing wrong?