未捕获的类型错误:对象 #<对象> 没有方法“on”
Uncaught TypeError: Object #<Object> has no method 'on'
我收到未捕获的类型错误:对象#在页面的实时版本上没有方法'on',但在测试页面上错误没有显示...我哪里可能出错了?它有效和不起作用?
$(document).ready(function() {
$('#frequency_options').change(function(){
var selected = $(this).val();
if(selected == "1"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id ='radio1' name='day[]' value='Monday through Friday' /> Every <input type ='text' class ='text' id ='1' name='daily1[]' size ='1' value='1' /> day(s) Monday through Friday <br />");
$("#frequency_data").append("<input type ='radio' id ='radio2' name='day[]' value='Sunday through Saturday' /> Every <input type ='text' class ='text' id ='2' name='daily2[]' size ='1' value='1' /> day(s) Sunday through Saturday <br />");
}
if(selected == "2"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id ='radio3' name='week[]' /> Every week on the same day of the week from the start date(Monday , Tuesday , etc ..) <br />");
}
if(selected == "3"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id ='radio4' name='week[]' /> Every two weeks on the same day of the week from the start date (Monday , Tuesday , etc ..) <br />");
}
if(selected == "4"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id ='radio5' name='twice_month[]' value='twice_month1' /> On the <input type ='text' class ='text' id ='3' name='twice_per_month1[]' size ='1' value='1' /> day and <input type ='text' id ='4' class ='text' name='twice_per_month3[]' size ='1' value='15' />day of the month <br />");
$("#frequency_data").append("<input type ='radio' id ='radio6' name='twice_month[]' value='twice_month2' /> On the <input type ='text'class ='text' id='5' name='twice_per_month2[]' size ='1' value='1' /> and last day of the month <br />");
}
if(selected == "5"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id='radio7' name='four_weeks[]' /> Every four weeks on the same day of the week from the start date (Monday , Tuesday , etc ..) <br />");
}
if(selected == "6"){
$("#frequency_data").empty();
$("#frequency_data").append("<input type ='radio' id ='radio8' name='month[]' value='month1' /> <input type ='text' id ='6' class ='text' name='month_day[]' size ='1' value='15' /> day of <input type ='text' id='7' class ='text' name='monthly[]' size ='1' value='1' /> month <br />");
$("#frequency_data").append("<input type ='radio' id ='radio9' name='month[]' value='month2' /> <select name='day_order' class ='text' id='day_order'><option value='first'>First</option><option value='second'>Second</option><option value='third'>Third</option><option value='fourth'>Fourth</option><option value='last'>Last</option></select><select name='day_name' id='day_name'><option value='sunday'>Sunday</option><option value='monday'>Monday</option><option value='tuesday'>Tuesday</option><option value='wednesday'>Wednesday</option><option value='Thursday'>Thursday</option><option value='friday'>Friday</option><option value='saturday'>Saturday</option></select>day of every <input type ='text' id ='monthly_dropdown' name='monthly_dropdown[]' size ='1' value='1' /> month <br /> ");
$("#frequency_data").append("<input type ='radio' id ='radio10' name='month[]' value='month3' /> on the last day of every <input type ='text' id ='8' class ='text' name='last_day_monthly[]' size ='1' value='1' /> month <br />");
}
});
$(document).on('click', 'input[id^="1"]', function() {
$("#radio1").prop("checked", true)
});
$(document).on('click', 'input[id^="2"]', function() {
$("#radio2").prop("checked", true)
});
$(document).on('click', 'input[id^="3"]', function() {
$("#radio5").prop("checked", true)
});
$(document).on('click', 'input[id^="4"]', function() {
$("#radio5").prop("checked", true)
});
$(document).on('click', 'input[id^="5"]', function() {
$("#radio6").prop("checked", true)
});
$(document).on('click', 'input[id^="6"]', function() {
$("#radio8").prop("checked", true)
});
$(document).on('click', 'input[id^="7"]', function() {
$("#radio8").prop("checked", true)
});
$(document).on('click', 'input[id^="8"]', function() {
$("#radio10").prop("checked", true)
});
$(document).on('click', 'input[id^="day_order"]', function() {
$("#radio9").prop("checked", true)
});
$(document).on('click', 'input[id^="day_name"]', function() {
$("#radio9").prop("checked", true)
});
$(document).on('click', 'input[id^="monthly_dropdown"]', function() {
$("#radio9").prop("checked", true)
});
$(document).on('click', 'input[id^="last_day_monthly"]', function() {
$("#radio10").prop("checked", true)
});
/*
$('#events').submit(function(e) {
//prevent the default submithandling
alert( "Handler for .submit() called." );
e.preventDefault();
//send the data of 'this' (the matched form) to yourURL
$.post('http://www.hiu.edu/cms/events.php', $(this).serialize());
});
*/
});
鉴于该错误,有两种/三种可能性:
-
该页面的实时版本使用的是比页面的开发版本更旧版本的jQuery。
on
方法在jQuery 1.7中添加。解决方案:在开发和上线中使用相同的版本(理想情况下是最新版本)。
-
该页面的实时版本具有PrototypeJS,MooTools或其他定义
$
函数的东西,而不是jQuery。解决方案:确保将jQuery放在页面上,并处理与PrototypeJS/MooTools/任何与
noConflict
冲突。
实时版本有jQuery和PrototypeJS,MooTools或类似版本, jQuery首先加载,然后被PrototypeJS,MooTools或类似版本覆盖。
解决方案:看看如何使用
noConflict
。
相关文章:
- 对象文字方法上的Javascript绑定不起作用
- 如何在ajax中调用javascript对象的方法
- 解析带有嵌入式数组的JSON对象,方法
- 确定var是否是javascript中的elementFinder对象的方法是什么
- Javascript:对回调创建的对象执行方法
- 向通过ReST JSON调用生成的Angular Javascript对象添加方法
- 有没有办法在应用程序脚本中使用JavaScript为对象创建方法字典
- Rally SDK 2 标签选择器是否有必填字段?对象没有方法'getContextPath'
- 按键名调用 JSON 对象的方法有什么区别
- Box2dWeb中是否有方法将对象的位置.x输出到console.log()
- javascript构建对象.有什么区别和最好的方法
- 在反序列化JSON对象时,是否有方法将属性名称转换为小写?
- 这两种定义类/对象的方法有什么区别?
- 是否有可能发送我的对象与方法(函数)从服务器到客户端
- 有没有一种方法可以在不修改Object.prototype的情况下给所有对象一个方法?
- 这两种获取画布对象的方法有什么区别?
- 解析JSON字符串后是否有方法获得对象属性
- 检查对象是否有方法,而不实例化它
- 如果访问amazon s3对象,是否有方法调用lambda函数?
- 在Python中是否有向对象添加方法的惯用方法?