2013-01-10 47 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 
    } 
}); 

願這可以幫助別人!