Javascript 使用Firefix插件获得Alexa等级

Javascript 使用Firefix插件获得Alexa等级,javascript,Javascript,现在我有两种使用API获取alexa rank的方法,但我个人发现第二种方法在不使用xmlhttp的情况下更好更简单 1使用php,但我被困在如何使用javascript在FirefoxSDK中显示这一点上。我尝试过使用xmlhttp,但不知何故出现了错误 <?php $url = "https://www.google.com.my/?gws_rd=cr,ssl&ei=UCbJVMO-KZfe8AW-yYKICQ"; $xml = simplexml_load_file('htt

现在我有两种使用API获取alexa rank的方法,但我个人发现第二种方法在不使用xmlhttp的情况下更好更简单

1使用php,但我被困在如何使用javascript在FirefoxSDK中显示这一点上。我尝试过使用xmlhttp,但不知何故出现了错误

<?php
$url = "https://www.google.com.my/?gws_rd=cr,ssl&ei=UCbJVMO-KZfe8AW-yYKICQ";
$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url='.$url);
$rank = isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;
$web = (string)$xml->SD[0]->attributes()->HOST;
$backlink = (int)$xml->SD[0]->LINKSIN->attributes()->NUM;

echo $rank;
?>
var Request = require("sdk/request").Request;

var quijote = Request({     
    url: "http://data.alexa.com/data?cli=10&dat=snbamz&url=www.google.com",
    overrideMimeType: "application/xml; charset=latin1",
    onComplete: function (response) {
        xml = response.text;
        console.log(xml);
        var a = xml.getElementsByTagName("POPULARITY");
        console.log(xml[0].attributes[1].nodeValue);
    }
});
quijote.get();