Display message on success does not work
<p>I have a simple wishlist script written in Javascript that adds an item into a wishlist. The script adds the item successfully into the user's list but I can't seem to display a success message.</p>

<p>I'm using the code below to try and display the success message. The script initially worked then just suddenly stopped working.</p>

<pre><code>function AddItem(ToDoItem) {
    if ((ToDoItem != null) &amp;&amp; (ToDoItem != "undefined" )) {
        NumToDoItems++;
        SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
        SetCookie('PT_NumToDoList',NumToDoItems, exp);
        $(window).humanMsg('Added '+ToDoItem+' to Wishlist');
    }
}
</code></pre>

<p>Can you please have a look at the code and provide me some advice? </p>

<p>More info:</p>

<p>My html:</p>

<pre><code>&lt;div class="add-to-wishlist"&gt;
&lt;a href="javascript:AddItem('&lt;?php print htmlentities($title, ENT_QUOTES); ?&gt;')"&gt;
&lt;img class="add-to-wishlist" src="/images/add-to-wishlist-button.gif" border="0" /&gt;&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>Here is the humanMsg. plugin for jQuery</p>

<pre><code>(function($, window){

$.fn.humanMsg = function( message, options ) {
    return this.each(function(){
        var container = this == window || this == document ? document.body : this;
        !$.data(container, 'humanMsg') &amp;&amp; $.data(container, 'humanMsg', new     $.humanMsg (container, message, options) );
    });
};

$.humanMsg = function( container, message, options ) {
    if (typeof message == 'object') {
    options = message;
    message = null;
}

var s = $.extend({}, $.humanMsg.defaults, options);

var $m,
    sizeContainer = container == document.body ? window : container;

$m = $('&lt;div class="humanized-message '+s.addClass+'"/&gt;')
.html(message || s.message)
.click(remove)
.appendTo(container);

$m.css({
    display: 'none',
    visibility: 'visible',
    top: ($(sizeContainer).height()-$m.innerHeight())/2,
    left: ($(sizeContainer).width()-$m.innerWidth())/2
})
.fadeIn(s.speed);

s.autoHide &amp;&amp; setTimeout(remove, s.autoHide);   

function remove() {
    $m.fadeOut(s.speed, function(){
        $m.remove();
        $.removeData(container, 'humanMsg');
    });
}

};

$.humanMsg.defaults = {
message: 'no message was set',
autoHide: 3000,
addClass: '',
speed: 300
};

})(jQuery, this);
</code></pre>

<p>Looking into the error console I have this:</p>

<pre><code>Uncaught TypeError: Property '$' of object [object Window] is not a function 
(anonymous function)
closing script tag manually 
</code></pre>
