小编Pha*_*une的帖子

同步GM_xmlhttpRequest异步执行?

我试图接到一个GM_xmlhttpRequest同步行为的电话,但我不能像我期望的那样让它工作:

function myFunction (arg) {
    var a;

    GM_xmlhttpRequest ( {
        method:         "GET",
        url:            "http://example.com/sample/url",
        synchronous:    true,

        onload: function (details) {
            a = details.responseText;
        }
    } );

    return a;
}
b = myFunction ();
alert (b);
Run Code Online (Sandbox Code Playgroud)

我从来没有得到任何回报b; 这是未定义的.我在这里缺少一些步骤吗?
我使用的是Greasemonkey的v0.9.13和Firefox的v9.0.1.

synchronization greasemonkey gm-xmlhttprequest tampermonkey

2
推荐指数
1
解决办法
2926
查看次数