2013-01-10 51 views
0

我想在我的web应用程序中使用谷歌字体。我的呼叫加载谷歌的字体是:如何在IE,Firefox和Chrome中使用谷歌网页字体

$.get("https://www.googleapis.com/webfonts/v1/webfonts?key=xxxxxxx", function (result) {            
     var data = {}; 
     console.log(result); 
     console.log($.parseJSON(result)); 
     data.items = $.parseJSON(result).items; 
}); 

上述呼叫给出以下结果在我3个靶浏览器:

火狐

console.log(result);    ========> JSON string 
console.log($.parseJSON(result)); ========> Successfully parsed the json string 
data.items = $.parseJSON(result).items; ===> contains all google fonts 

IE(9)

$.get callback is not executing. 

console.log(result);    ========> Object 
console.log($.parseJSON(result)); ========> null 

可有人告诉我使用谷歌的字体在所有上述3所述浏览器的通用方法是什么?

回答

0

我发现了一个广义的调用,它在Firefox,IE和Chrome的工作:

$.ajax({ 
    url: "https://www.googleapis.com/webfonts/v1/webfonts?key=xxxxx", 
    type: 'GET', 
    dataType: 'JSONP', 
    success: function (data) { 
     // data.items contains all google font-families name 
    } 
}); 

愿这可以帮助别人!