使用请求mod使用firefox附加sdk检索json字符串中的变量

I have a php script on my server where i get vars from database and this script return a json string like this sample with images urls :

[ { 'src':'imageurl1'} , { 'src':'imageurl2'}, ... ]

In my add-on i put the following code to retrieve by request

var imgs; 

Request({

    url: "http://www.page.com/get.php",

    onComplete: function (response) {
        imgs = response.json;
    }

});

and send to a 'script.js' the values

pageMod.PageMod({

    include: "domain.com",
    contentScriptFile: data.url("script.js"),
    attachTo: ["top"],
    onAttach: function(worker) {
        worker.port.emit("imgs",imgs);
    }

});

But it dont work. Whats wrong ?

It's a slightly odd detail of the request module, you need to first create the request object ( as you did ) and then you need to call the get method on it:

var imgs; 

Request({

    url: "http://www.page.com/get.php",

    onComplete: function (response) {
        imgs = response.json;
    }
}).get();
// ^^^^^ <-- you need to call this method.

Does that help?