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 ...
随机推荐
- 一个tomcat同时部署多个项目
一个tomcat同时部署多个项目 1. 注意事项: 1. 每一个service的端口号不能产生冲突 2. service的name属性的值可以重复 name="Catalina" ...
- python生成图片二维码(利用pillow)
首先 pip install pillow 然后 from PIL import Image from PIL import ImageDraw from PIL import ImageFont i ...
- Linux(CentOS7)下安装Mysql8数据库
一.Linux版本 二.先下载Linux下的Mysql包,打开Mysql官网 https://www.mysql.com/ 点击DOWNLOAD,进入 https://www.mysql.com/do ...
- 进程间通信之数据传输--Socket
The client server model Most interprocess communication uses the client server model. These terms re ...
- Linux core dump总结
文章链接:https://www.cnblogs.com/Anker/p/6079580.html 1.前言 一直在从事linux下后台开发,经常与core文件打交道.还记得刚开始从事linux下开发 ...
- Beta冲刺(6/7)——2019.5.27
所属课程 软件工程1916|W(福州大学) 作业要求 Beta冲刺(6/7)--2019.5.27 团队名称 待就业六人组 1.团队信息 团队名称:待就业六人组 团队描述:同舟共济扬帆起,乘风破浪万里 ...
- js延迟加载的性能优化
js的延迟加载有助于提高页面的加载速度,特别是竞价优化站是有一定的好处,今天来说说我是如何优化竞价站打开速度! 案例:http://yzmb.pengchenggroup.cn/ 动态创建DOM方式 ...
- php长连接和短连接区别
短连接 连接->传输数据->关闭连接(推荐学习:PHP编程从入门到精通) 比如HTTP是无状态的的短链接,浏览器和服务器每进行一次HTTP操作,就建立一次连接,但任务结束就中断连接. 具体 ...
- python应用-表格式输出一组数据
def main(): names=['关羽','张飞','赵云','马超','貂蝉'] subjects=['语文','数学','Python'] table=[[0 for _ in range( ...
- 29、Python程序中的进程操作(multiprocess.process)
一.multiprocess模块 multiprocess不是一个模块而是python中一个操作.管理进程的包. 子模块分为四个部分: 创建进程部分 进程同步部分 进程池部分 进程之间数据共享 二.m ...