Search code examples
jqueryyql

The "property" property of the meta tag is missing in response when getting open graph data, using jquery, cross-domain ajax and YQL


I'm using jquery 1.5.1, James Padolsey Cross Domain Ajax 0.11 which uses YQL to get external sites.

this is my code

$.ajax({
        url: "http://ogp.me/",
        type: "GET",
        crossDomain: true,
        success: function (res) {
        console.log($(res.responseText));
 });

The problem is that in the responseText, all meta tags are missing the "property" property.

this is what the source code of the page looks like:

<meta property="og:title" content="Open Graph Protocol" />

this is what firebug shows the responseText value is:

<meta content="Open Graph Protocol"/>

Is this a YQL problem? Is there a better way to get open graph data from external sites?


Solution

  • YQL's html data table, which is being used by that cross-domain AJAX plugin, runs HTML Tidy (info) on the HTML returned from the remote server. During this process, the property attributes that you are looking for are removed (likely because Tidy sees them as invalid).