我有以下代码
$(".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中的开发工具截图