当使用JQuery的"$",抛异常Uncaught TypeError: Object #<Object> has no method 'ajax'
2014-07-21 09:41
821 查看
问题:
当以如下形式使用jQuery的ajax时,出现异常。
$.ajax({ url: '<?php echo get_template_directory_uri() ?>/api/json.file.php', data: "", dataType: 'json', success: function(data) { } });
原因:
在你引入的js文件中,把变量$覆盖了,而覆盖之后的$变量却没有‘ajax’方法[/code]方法:
使用console.log($)输出信息进行判断,该变量是否为Jquery对象
解决途径:
1、在不影响其他js功能的情况下,改变引入js文件的顺序,使得jQuery的$变量覆盖其他的文件中定义的$变量
2、将$.ajax()改为JQuery.ajax(),也就是用JQuery(或jquery)代替$.
相关文章推荐
- Uncaught TypeError: Object #<HTMLDivElement> has no method 'attr'
- Uncaught TypeError: Object #<Object> has no method 'addEvents' ext-all-debug异常
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- 出现TypeError: Object #<Object> has no method 'createClient' 错误
- TypeError: Object #<Object> has no method 'createClient'
- sencha touch中出现JS错误Uncaught TypeError: Object [object Object] has no method 'getForm'
- jquery dialog异常 Uncaught TypeError: Object [object Object] has no method 'dialog'
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- Uncaught TypeError: Object #<Document> has no method 'load'
- Uncaught TypeError: Object [object Object] has no method 'live' 报错
- WebView注入Java对象注意事项 [INFO:CONSOLE(475)] "Uncaught TypeError: Object [object Object] has no method
- Uncaught TypeError: Object #<HTMLCollection> has no method 'toLowerCase'问题
- Uncaught TypeError: Object [object Object] has no method 'xxx'
- [Android] Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
- Uncaught TypeError: Object [object Object] has no method 'highcharts'
- Uncaught TypeError: Object [object Object] has no method 'live'
- JS调用Android中的方法时出现 "Uncaught TypeError: Object [object Object] has no method
- [Python][转]Exception AttributeError: "'NoneType' object has no attribute
- jQuery File upload, Uncaught TypeError: Object function ... ... has no method 'widget'
- Uncaught TypeError: Object #<Object> has no method 'fancybox'