This is my code:
// ==UserScript==
// @name Test1
// @namespace http://my_unique_namespace.com
// @version 1
// @include http*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_log
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// ==/UserScript==
function testReq() {
GM_xmlhttpRequest({
method: "GET",
url: "http://www.google.com",
onload: function(response) {
alert(response.responseText);
},
onerror: function(reponse) {
alert('error');
}
});
}
testReq();
GM_log("This works");
/*
Exception: GM_xmlhttpRequest is not defined
testReq@Scratchpad/1:15
@Scratchpad/1:27
*/
My problem is that I'm getting the exception listed at the bottom of the code sample every time I run the script, but the GM_xmlhttpRequest seems to be working (I successfully get the response object).
Any ideas why this is happening?
Thank you.
Update: Greasemonkey 1.8 on Windows 7 Professional 64-bit
This happened about 1 month ago in google-chrome-beta.i386 for Fedora 17. Removed beta. Installed google-chrome-stable.i386. Problem resolved.
On latest update today for chrome-stable this problem reoccurs. Version is 27.0.1453.93.
Script in question which runs GM_xmlhttpRequest is a .user.js script installed manually into Extensions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.