0

I am trying to use google fonts in my web application. My call to load google fonts is :

$.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;
});

The above call gives following result in my 3 target browsers :

Firefox

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.

Chrome

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

Can anybody please tell me the generalized way to use google fonts on all above 3 mentioned browser?

Tom Rider
  • 2,747
  • 7
  • 42
  • 65

1 Answers1

0

I found a generalized call which works on Firefox, IE and 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
    }
});

May this helps to others !

Tom Rider
  • 2,747
  • 7
  • 42
  • 65