jquery ajax Uncaught TypeError :Illegal invocation 报错
使用jquery ajax异步提交的时候报Uncaught TypeError :Illegal invocation错误,报错如图:

基本上,导致这个错误的原因一般有以下两点:
1.请求类型有误,如,post请求,但在后台设置的是get请求
2.参数有误。 如,没有传参,或是参数对应不上去
经过排查我违反了上面的第二点,传入的参数是一个对象,没有转为字符串,所以报错,代码如下:
$(function() {
$( "#tagging" ).click(function() {
var mytext = x.Selector.getSelected();
var word_id = $('#word_id').val();
if (mytext == '') {
alert("请选中文本后再进行标注");
}
else if (word_id <= ) {
alert("操作失败");
}
else {
// var data = {word_id: word_id, mytext: mytext.toString()};
var data = {word_id: word_id, mytext: mytext};
$.ajax({
type: "POST",
url: 'ajax.php',
data: data,
success: function( data, textStatus, jQxhr ){
alert(data);
},
error: function( jqXhr, textStatus, errorThrown ){
alert(data);
}
});
}
});
});
使用 .toString() 将对象转为字符串,再去请求就成功了。
jquery ajax Uncaught TypeError :Illegal invocation 报错的更多相关文章
- Ajax方式上传文件报错"Uncaught TypeError: Illegal invocation"
今天使用ajax上传文件时,出现了错误.数据传输的方式是通过定义formData完成的,提交的文件对象也设置为dom对象,但是还是不能发送请求.F12看到后台报了个错误:Uncaught TypeEr ...
- Uncaught TypeError: Illegal invocation
Jquery实现Ajax异步提交时报错"Uncaught TypeError: Illegal invocation",如下图: 排查发现错误在于此: 复制代码代码如下: data ...
- jQuery-2.1.4.min.js:4 Uncaught TypeError: Illegal invocation
jQuery-2.1.4.min.js:4 Uncaught TypeError: Illegal invocation 此错误与crsf有关
- [BUG]Uncaught TypeError: Illegal invocation at HTMLDivElement.
<div id="clickMe" key="1">点我</div> clickMe.onclick = function (event ...
- jS Ajax 上传文件报错"Uncaught TypeError: Illegal invocation"
使用jquery ajax异步提交文件的时候报Uncaught TypeError :Illegal invocation错误,报错信息如图: 错误原因: jQuery Ajax 上传文件处理方式,使 ...
- Uncaught TypeError: Illegal invocation解决
jquery中报了这个错,仔细一看,有个使用ajax的地方,其中有个参数是从页面某个文本框获取的,本应该 $('#id').value ,被我写成了 $('id') .所以报错,目前已解决.
- jquery 报错 Uncaught TypeError: Illegal invocation
遇到这个错误 请检查你的ajax提交方法的参数 1 参数是否都有定义 2 参数个数是否一致 3参数是否都有值(******)
- ajax--表单带file数据提交报错Uncaught TypeError: Illegal invocation
只要设置 contentType: false, //不设置内容类型 processData: false, //不处理数据 $("#btn").on("click&qu ...
- 【jQuery】jquery中 使用$('#parentUid').attr(parentUid);报错jquery-1.11.3.min.js:5 Uncaught TypeError: Cannot read property 'nodeType' of undefined
jquery中 使用$('#parentUid').attr(parentUid);报错jquery-1.11.3.min.js:5 Uncaught TypeError: Cannot read p ...
随机推荐
- tail: inotify cannot be used, reverting to polling: Too many open files
tail -f catalina.out 出现警告: tail: inotify cannot be used, reverting to polling: Too many open files l ...
- Centos6.5配置防火墙
1.查看防火墙状态 [root@instance-xfl1djr7 ~]# /etc/init.d/iptables status 2.启动/关闭防火墙 开启防火墙 [root@instance-xf ...
- zabbix3.4中报错解:telnet service is down on决方法
当新添加的监控主机报telnet service is down on的时候,大家不要惊慌,这个是属于模板中添加了一项监控参数,监控被监控机的telnet服务,有两种解决办法,第一呢就是找到对应的监控 ...
- 解决网页刷新时,隐藏div元素闪现问题
最近项目遇到一个问题,需要对一个div中的元素设置根据不同的情况进行显示和隐藏. 因为默认该div是显示的,所以在刷新页面的时候,会先加载这个div进行显示,加载完成后又执行到 hide() 方法,使 ...
- FreeBSD安装过程
对于现在版本,安装过程中该使用哪些键,现简单总结: Space:选中/取消选中: Tab:切换,主要是分区界面时用它选择输入行: Enter:确定(并进入下一页): 方向键:在一些子组里更换输入项得用 ...
- 蓝桥杯如何训练?(附VIP题库)
https://www.dotcpp.com/ 给大家介绍下蓝桥杯,是近几年可以说国内名气最大的程序设计类比赛了 相比国际赛事ACM,蓝桥杯入门简单.中文答题.拿奖率高,更适合国内大众化参加,近几年不 ...
- C# 中静态调用C++dll 和C# 中动态调用C++dll
在最近的项目中,牵涉到项目源代码保密问题,由于代码是C#写的,容易被反编译,因此决定抽取核心算法部分使用C++编写,C++到目前为止好像还不能被很好的反编译,当然如果你是反汇编高手的话,也许还是有可能 ...
- PLSQL 美化规则文件详解
PL/SQL中有个代码优化的功能,里面可以定义规则,挺好用的,跟大家分享下: 1.首先新建一个my.br文件,在文件中复制以下内容 Version=1 RightMargin=90 Indent=4 ...
- Caching POST-post是否能缓存
https://www.mnot.net/blog/2012/09/24/caching_POST One of the changes in Apple’s release of iOS6 last ...
- linux MySQL5.7 rpm安装(转)
删除旧包: # rpm -qa | grep -i mysql # rpm -ev mysql-libs-* --nodeps 安装rpm包: # rpm -ivh mysql-community-c ...