On page load, I'm making two AJAX requests: one to pull the newest video from a Youtube channel, and one to pull the newest post from a blog. Both scripts work correctly.
For whatever reason, I haven't been able to test it in any browser (Chrome, Firefox, Safari, and Opera). Is the request too big? I've been running into issues with CORS support (at least that's what I think is going on) while using Chrome, so the blog request isn't working there and completely offsets the video request (it doesn't work).
Here's the error I get in the Javascript Dev Console in Chrome:
XMLHttpRequest cannot load http://devingraham.blogspot.com/rss.xml. Origin null is not allowed by Access-Control-Allow-Origin.
If I change...
var tmp = $(this).find("content:first").text();
...to just find the "title:first" instead, it renders fine in Safari without freezing. If I keep it at content and load the page, I can see the post loads in just fine, but the page freezes and won't load the video. So perhaps it's just too much? I know for a fact that the post I'm pulling is quite long, but it seems silly that it would cause any issues. So do you have any ideas?
Here's the script:
<script type="text/javascript" charset="utf-8">
$(function() {
$.ajax({
type: "GET",
url: "http://gdata.youtube.com/feeds/base/users/devinsupertramp/uploads?orderby=updated&alt=rss&client=ytapi-youtube-rss-redirect&v=2",
dataType: "xml",
success: parseVideo
});
$.ajax({
type: "GET",
url: "http://devingraham.blogspot.com/rss.xml",
dataType: "xml",
success: parseBlog
});
});
function parseVideo(xml) {
$(xml).find("item:first").each(
function() {
var tmp = $(this).find("link:first").text();
tmp = tmp.replace("http://www.youtube.com/watch?v=", "");
tmp = tmp.replace("&feature=youtube_gdata", "");
tmp2 = "http://www.youtube.com/embed/" + tmp + "?autoplay=1&controls=0&rel=0&showinfo=0&autohide=1";
var iframe = $("#ytplayer");
$(iframe).attr('src', tmp2);
}
);
}
function parseBlog(xml) {
$(xml).find("entry:first").each(
function() {
var tmp = $(this).find("content:first").text();
var post = $("#blog");
post.append(tmp);
}
);
}
</script>