I use this script (does a document.write, you can visit the src to see it), which spends time loading as soon as it is reached in the HTML sequence of my pages:
<script type="text/javascript" src="http://pkmncards.disqus.com/recent_comments_widget.js?num_items=25"></script>
This prevents anything after the script from loading for a second or two while it loads, so instead I want to load it via jQuery Ajax to prevent the hangup.
Here's what I've attempted:
var $j = jQuery.noConflict();
$j(document).ready(function () {
$j.ajax({
url: "http://pkmncards.disqus.com/recent_comments_widget.js?num_items=25",
dataType: "script",
success: function (data) {
$j("#recent-discussion").html(data)
}
});
});
However I'm not handling the success properly. I see the request load, but it doesn't do anything. I want it to run the script and output the document.write into the target #recent-discussion.
I'm still searching for examples but can't figure out what I'm doing wrong... any help is much appreciated!
scripttag to the bottom?