JQuery Post的问题

时间:2012-09-27 13:29:20

标签: jquery

我已经关注了代码

$(".momentoCommentArea").on('keypress',function(event) {
    console.log(event.which); //mypublicpost.js:42
    if (event.keyCode == 13) { //enterkey //mypublicpost.js:43
        var message = $(".momentoCommentArea").val(); //mypublicpost.js:44
        //mypublicpost.js:44
        $.post('momento/newComment',  //mypublicpost.js:46
                    {'picaid':currentFid,'msg':message},
                    function(data){
                var tComment=$("<div></div>").addClass('momento-comment');
                var imgUrl=$("#siddlb-comments").children(".momento-comment").children('.momento-comment-img').children('img').attr('src');
                $("<div></div>").addClass('momento-comment-img').html('<img src="'+imgUrl+'" width="40" height="40" />').appendTo(tComment);
                $("<div></div>").addClass('momento-comment-comment').html("<b>"+$("#membername").html()+"</b><br/>"+message).appendTo(tComment);
                $("<div></div>").addClass('momento-comment-date').html('This seccion').appendTo(tComment);
                $("#momento-comments > div.momento-comment:first").before(tComment);
        });
    }
});

运行代码(在textarea中输入文本并按Enter键)会产生以下错误:

Uncaught TypeError: Illegal invocation jquery-1.7.2.js:7740
  jQuery.extend.param.add jquery-1.7.2.js:7740
  buildParams jquery-1.7.2.js:7797
  buildParams jquery-1.7.2.js:7792
  buildParams jquery-1.7.2.js:7792
  buildParams jquery-1.7.2.js:7792
  buildParams jquery-1.7.2.js:7792
  buildParams jquery-1.7.2.js:7792
  buildParams jquery-1.7.2.js:7792
  jQuery.extend.param jquery-1.7.2.js:7760
  jQuery.extend.ajax jquery-1.7.2.js:7606
  jQuery.each.jQuery.(anonymous function) jquery-1.7.2.js:7245
  (anonymous function) mypublicpost.js:45  //EDIT: line 45 is $.post line
  jQuery.event.dispatch jquery-1.7.2.js:3332
  jQuery.event.add.elemData.handle.eventHandle

有人可以建议这个错误意味着什么,我应该如何解决这个错误?

修改

chrome中的开发工具的屏幕截图

enter image description here

1 个答案:

答案 0 :(得分:1)

上述评论摘要:

这似乎是提供给JSON数据的非法变量的简单情况......带有非常广泛的错误消息。