我正在尝试在我的网络应用程序中使用谷歌字体。我对加载谷歌字体的呼吁是:
$.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 :(得分: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
}
});
这对其他人有帮助!