2

jQuery is throwing the following error:

Uncaught TypeError: Object # has no method 'apply'

f.event.dispatch

h.handle.i

I've found these related posts, but couldn't solve the problem using them: This, this and this.

Here's the troublesome code:

$(document).ready(function(){
$('form.rating').click({
    cancelShow:true,
    callback: function(ui, type, new_value) {
        var values = ui.$form.serializeArray();
        values.push({
            'name': 'rating',
            'value': new_value
        });
        values = jQuery.param(values);
        var msg = ui.$form.attr('update-msg');
        $(msg).removeClass('hidden');
        $(msg).show();
        $(msg).find('div.msg-default').show();
        $(msg).find('div.msg-result').hide();
        $.ajax({
            'type': 'POST',
            'dataType': 'json',
            'url': ui.$form.attr('action'),
            'data': values
        }).done(function(data) { 
            var overall_rating = ui.$form.attr('update-overall');
            if(overall_rating && data['overall_rating']){
                $(overall_rating).html(data['overall_rating']);
            }
            if(msg){
                $(msg).find('div.msg-default').hide();
                if(data['msg']) {
                    $(msg).find('div.msg-result').show();
                    $(msg).find('div.msg-result').html(data['msg']);
                    window.setTimeout(function() {
                        $(msg).addClass('hidden');
                    }, 2000);
                } else {
                    $(msg).addClass('hidden');
                }
            }
            if(data['user_rating'] && data['user_rating']>0) {
                ui.select(parseInt(data['user_rating']));
            }
        });
    }
});
});

Any ideas?

Edit: Okay, so I stripped it down to:

$(document).ready(function(){
    $('form.rating').click({
    });
});

And it is still showing the same error. Could this have something to do with my jQuery script? The only other info it shows is this line, but I don't think it helps much, since the file has 3 lines in total: jquery-1.7.2.min.js:3


And the formula you are using is not correct cause you are not calculating the square of the standard deviation.

4

2 に答える 2

5

jquery クリック ハンドラーは、次のような無名関数を想定しています。

$(document).ready(function(){
    $('form.rating').click(function() {
        // go for it!
    });
});
于 2013-03-20T14:38:06.877 に答える