I am attempting to get an embedded version of Instagram posts in my HTML. I get the HTML that I want to use through an ajax call.
My ajax call is working and I am getting the HTML since I see it in my console.log
however nothing appears and no errors are shown when I load up the page.
Here is the ajax call:
function getIFrame(url) {
var embedUrl = "http://api.instagram.com/oembed?url=" + url;
$.ajax({
type: "GET",
url: embedUrl,
crossDomain: true,
headers: { 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT' },
async: true,
dataType: "jsonp",
success: function (data) {
console.log(data.html);
return data.html;
}
});
}
and here is a snippet of what is using it.
...
$('<div>', { "style" : "padding-top: 10px;"})
.append($('<span>').addClass('bold').text("User Website: "))
.append(getIFrame(urlIG)),
...
The console.log
outputs the HTML fine to the console but it does not show up in the HTML.
For reference here is where I got the embed information: https://instagram.com/developer/embedding/
and here is a sample of the JSON (same example as the API): http://api.instagram.com/oembed?url=http://instagr.am/p/fA9uwTtkSN/