The script I'm using to redirect my homepage isn't working the way I need it to

The script I'm using to redirect my homepage isn't working the way I need it to

I'm using the jquery script below to redirect my tumblr homepage to my latest post.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script>
$
(document).ready(function() {
   $
.getJSON('http://mydomain.tumblr.com/api/read/json?callback=?', function(result) {
      window
.location.href = result.posts[0].url;
   
});
});
</script>

I'm having two problems with it. First, it doesn't redirect instantly, it loads my homepage and then changes the URL, even though I've placed it above my  <head>  tag, which I'm guessing has something to do with  $(document).ready. Then when it does redirect it starts refreshing every few seconds. Thanks for any help!