Home > front-end development, jquery > Give your error pages extra FAIL

Give your error pages extra FAIL

January 22nd, 2009

A site I'm currently working has had boring and barren error pages. Until now!

I wanted some images from failblog.org to liven things up a bit. In a quick 20 minute hack, I took the site's rss feed, parsed it for the right content using Yahoo Pipes, exported as JSON-P, pulled that in with jQuery, and displayed a random image.

Here's the pipe I'm using:

The trick to pulling in Yahoo Pipe data via JSON-P is by adding a "_callback" argument, defining the callback function name.

The script:

jQuery.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=0vxHL0Lo3RGc2uL8pQt1Yg&_render=json&_callback=FailImages&callback=?');

function FailImages(data){
  var imgs = data.value.items;
  if (imgs){
    var url = imgs[Math.floor(Math.random()*imgs.length)].url;
    jQuery('< img src="'+url+'">').insertAfter('h1');
  }
}

The result:
2009-01-22_2049.png

And of course..
Demo page

front-end development, jquery

  1. January 22nd, 2009 at 21:05 #1

    I should point out this feed is not always SFW so use it as your discretion. This is more of an example of fux0ring with rss feeds and jsonpslamming them into your site. :)

  2. January 23rd, 2009 at 03:56 #2

    This wins so much interbutt.

  1. No trackbacks yet.

For code blocks, use <pre lang="javascript">. css and html4strict are also accepted.