初学者jquery $.ajax求大虾指点,提示对象不支持属性和方法 内含源码 本帖最后由 liugwind 于 2012-07-03 16:34:33 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先Firebug下看看jquery.js文件有没有正确加载,加载失败的话会报404错误的。 是请求没有成功,hia是请求根本就没发送 jquery.js是已经正确加载了 ,我把<script language="JavaScript" type="text/javascript" >function getVideoHit(vid){ $.ajax({ type: 'get', url: '/temp/hudong/info.php?action=hit', data: 'id='+vid, success:function(obj){ } });}</script>这段代码去掉完全没有错误 猜测会不会是因为缓存的缘故导致的,如果是这样的话,你可以试一试吧get方法改成POST方法 贴一下JQUERY库 jQuery JavaScript Library v1.3.2 ,由于文件太大贴不下/* * jQuery JavaScript Library v1.3.2 * http://jquery.com/ * * Copyright (c) 2009 John Resig * Dual licensed under the MIT and GPL licenses. * http://docs.jquery.com/License * * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) * Revision: 6246 */ 我的QQ是 1742-912 你的QQ多少 具体的错误信息是什么、哪一行?如果是$未定义,那就是jquery.js没加载进来。 <script language="JavaScript" type="text/javascript" >function getVideoHit(vid){ $.ajax({ type: 'get', url: '/temp/hudong/info.php?action=hit', data: 'id='+vid, success:function(obj){ } });}</script>改为<script language="JavaScript" type="text/javascript" >function getVideoHit(vid){ $("#hit") ; //没有错误 $("#hit").html("somedata") ; //提示错误 , null为空或不是对象}</script> $( "#hit ") ; //没有错误 $( "#hit ").html( "somedata ") ; //提示错误 , null为空或不是对象 无法想象出是啥错误 FIREBUG控制台输出:$("#hit") is nullhttp://www.dy800.cc/35822.htmLine 21 font标签实在太过时了,用span代替试试:<span style="color:red;" id="hit"></span> 好的谢谢 初步原因已经查明, 源程序里面加载了一个 max文件/*'******************************************************************************************' Software name: Max(马克斯) Content Management System' Version:4.0' Web: http://www.maxcms.net' Author: 石头([email protected]),yuet,长明,酒瓶 ' Copyright (C) 2005-2009 马克斯官方 版权所有' 法律申明:MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任'*******************************************************************************************/这里面有一段 eval代码 可能是这个代码覆盖了$这个 js随机取整数 有趣的JS上传按钮的问题 淘宝首页图片轮转广告 js cookie如何保存用户登陆信息? 如何获取iframe编辑器的值 分析别人网站的JavaScript代码 几乎不可能实现的高级打印问题:几个iFrame同时打印 有一页面需要输入密码后才能打开,我想用javascript实现,请问有办法吗? 项目中的一个问题,急待解决,请帮忙,谢谢 Extjs4 TreePanel的CheckBox列选中问题 JS如何设定<META NAME="Description" CONTENT="">? ]ExtJs4]怎样通过单击事件显示一个grid
jquery.js是已经正确加载了 ,我把
<script language="JavaScript" type="text/javascript" >
function getVideoHit(vid){
$.ajax({
type: 'get',
url: '/temp/hudong/info.php?action=hit',
data: 'id='+vid,
success:function(obj){
}
});
}
</script>
这段代码去掉完全没有错误
如果是这样的话,你可以试一试吧get方法改成POST方法
/*
* jQuery JavaScript Library v1.3.2
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
* Revision: 6246
*/
我的QQ是 1742-912 你的QQ多少
function getVideoHit(vid){
$.ajax({
type: 'get',
url: '/temp/hudong/info.php?action=hit',
data: 'id='+vid,
success:function(obj){
}
});
}
</script>改为<script language="JavaScript" type="text/javascript" >
function getVideoHit(vid){
$("#hit") ; //没有错误
$("#hit").html("somedata") ; //提示错误 , null为空或不是对象
}
</script>
$( "#hit ").html( "somedata ") ; //提示错误 , null为空或不是对象
无法想象出是啥错误
FIREBUG控制台输出:
$("#hit") is null
http://www.dy800.cc/35822.htm
Line 21
<span style="color:red;" id="hit"></span>
好的谢谢 初步原因已经查明, 源程序里面加载了一个 max文件
/*'******************************************************************************************
' Software name: Max(马克斯) Content Management System
' Version:4.0
' Web: http://www.maxcms.net
' Author: 石头([email protected]),yuet,长明,酒瓶
' Copyright (C) 2005-2009 马克斯官方 版权所有
' 法律申明:MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
这里面有一段 eval代码 可能是这个代码覆盖了$这个