当使用JQuery的"$",抛异常Uncaught TypeError: Object #<Object> has no method 'ajax'
来源:互联网 发布:matlab mac破解版 编辑:程序博客网 时间:2024/06/06 00:20
问题:
当以如下形式使用jQuery的ajax时,出现异常。
$.ajax({ url: '<?php echo get_template_directory_uri() ?>/api/json.file.php', data: "", dataType: 'json', success: function(data) { } });
原因:
在你引入的js文件中,把变量$覆盖了,而覆盖之后的$变量却没有‘ajax’方法
方法:
使用console.log($)输出信息进行判断,该变量是否为Jquery对象
解决途径:
1、在不影响其他js功能的情况下,改变引入js文件的顺序,使得jQuery的$变量覆盖其他的文件中定义的$变量
2、将$.ajax()改为JQuery.ajax(),也就是用JQuery(或jquery)代替$.
0 0
- 当使用JQuery的"$",抛异常Uncaught TypeError: Object #<Object> has no method 'ajax'
- jquery: Uncaught TypeError: Object [object Object] has no method 'live'
- jquery dialog异常 Uncaught TypeError: Object [object Object] has no method 'dialog'
- Uncaught TypeError: Object [object Object] has no method 'live'
- Uncaught TypeError: Object [object Object] has no method 'xxx'
- Uncaught TypeError: Object [object Object] has no method 'highcharts'
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- js调用java方法的遇到的坑Uncaught TypeError: Object [object Object] has no method
- Uncaught TypeError: Object #<Object> has no method 'addEvents' ext-all-debug异常
- ztree “Uncaught TypeError: Object # has no method 'toLowerCase'”
- Uncaught TypeError: Object #<HTMLDivElement> has no method 'attr'
- Uncaught TypeError: Object #<Document> has no method 'load'
- Uncaught TypeError: Object #<HTMLCollection> has no method 'toLowerCase'问题
- jQuery File upload, Uncaught TypeError: Object function ... ... has no method 'widget'
- [Android] Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
- sencha touch中出现JS错误Uncaught TypeError: Object [object Object] has no method 'getForm'
- Uncaught TypeError: Object [object Object] has no method 'live' 报错
- HTML5页面开发的基础性模板
- BFS/DFS模板
- Velocity浅析及与Jsp、Freemarker对比
- linux下apache+tomcat的配置实现
- Spark快速上手之交互式分析
- 当使用JQuery的"$",抛异常Uncaught TypeError: Object #<Object> has no method 'ajax'
- 角度制(六十进制)经纬度换算成浮点数(十进制)
- 基于TINY4412的Andorid开发-------简单的LED灯控制
- socket阻塞与非阻塞,同步与异步
- 【Unity3D自学记录】Time.timeScale、游戏暂停
- Uva 133 The Dole Queue 双向约瑟夫环
- hdu 1896 Stones(优先队列)
- hdu 1686 Oulipo(KMP)
- getchar() 和getch()的区别。。