
js 报错Uncaught TypeError :Illegal invocation
js 报错Uncaught TypeError :Illegal invocation是怎么回事?
原因可能是ajax传递了对象,误将对象传递给ajax的post或者get参数了,如下:
var id = $("#id"); //这是个对象 $.post('{:U(\'lotRedEnvelope\')}',{id:id},function (res) { if(res.status == 1000){ $.alert(res.data.msg); window.setTimeout(function () { window.location.href = '{:U(\'index\')}'; },3000); }else if(res.status == 409){ $.alert(res.data.msg); }else{ $.alert(res.data.msg); } });
上面应该把$("#id") 改为 $("#id") .val();