xmlhttpRequest is not defined

I get a ReferenceError in the following userscript code:

// ==UserScript==
// @name          ...
// @namespace     ...
// @description   ...
// @include       ...
// @grant         GM_xmlhttpRequest
// ==/UserScript==

console.log(GM_info);
try
{
    console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState);
}
catch (e)
{
    console.log(e);
}
...

It first logs GM_info successfully, then logs the ReferenceError. (I'm using Firefox/Firebug.)

ReferenceError: GM_xmlhttpRequest is not defined

Why do I get this error?


Reinstalling the script fixed the problem. I didn't need to restart Firefox, but it may be helpful for other people. Brock's answer has helpful debugging tips for problems like this.


我遇到了同样的问题,并且为我解决了这个问题,在顶部添加了这个问题:

// @grant        GM_xmlhttpRequest
链接地址: http://www.djcxy.com/p/71596.html

上一篇: 测量android中不规则多边形的面积

下一篇: xmlhttpRequest未定义