Javascript 未捕获类型错误:对象#<;对象>;没有方法';在';

Javascript 未捕获类型错误:对象#<;对象>;没有方法';在';,javascript,jquery,Javascript,Jquery,我得到了未捕获的TypeError:Object#在页面的实时版本上没有“on”方法,但在测试页面上没有显示错误。。。我可能哪里出错了?它起作用了,不起作用了 $(document).ready(function() { $('#frequency_options').change(function(){ var selected = $(this).val(); if(selected == "1"){ $("#frequency_data").empty();

我得到了未捕获的TypeError:Object#在页面的实时版本上没有“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' />&nbsp;&nbsp; Every <input type ='text'   class ='text' id ='1' name='daily1[]' size ='1' value='1' />&nbsp; day(s) Monday through Friday <br />");
    $("#frequency_data").append("<input type ='radio' id ='radio2' name='day[]' value='Sunday through Saturday' />&nbsp;&nbsp; Every <input type ='text' class ='text' id ='2' name='daily2[]' size ='1' value='1' />&nbsp; day(s) Sunday through Saturday <br />");
    }
    if(selected == "2"){
    $("#frequency_data").empty();
    $("#frequency_data").append("<input type ='radio' id ='radio3' name='week[]' />&nbsp;&nbsp; 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[]' />&nbsp;&nbsp; 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' />&nbsp;&nbsp; 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' />&nbsp;&nbsp; On the <input type ='text'class ='text' id='5'  name='twice_per_month2[]' size ='1' value='1' />&nbsp; and last day of the month <br />");
    }
    if(selected == "5"){
    $("#frequency_data").empty();
     $("#frequency_data").append("<input type ='radio' id='radio7' name='four_weeks[]' />&nbsp;&nbsp; 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' />&nbsp;&nbsp; <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' />&nbsp;&nbsp; <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' />&nbsp;&nbsp; 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());
});
*/

});
$(文档).ready(函数(){
$(“#频率_选项”)。更改(函数(){
所选变量=$(this.val();
如果(所选==“1”){
$(“#频率数据”).empty();
$(“#频率数据”)。追加(“周一至周五的每一天
”; $(“#频率数据”)。追加(“每天周日至周六
”; } 如果(所选==“2”){ $(“#频率数据”).empty(); $(“#频率数据”)。追加(“从开始日期(星期一、星期二等)开始的一周中的同一天的每周”
; } 如果(所选==“3”){ $(“#频率数据”).empty(); $(“#频率#数据”)。追加(“从开始日期(周一、周二等)起每两周在一周的同一天进行一次”
; } 如果(选定==“4”){ $(“#频率数据”).empty(); $(“#频率#u数据”)。追加(“在当月的日期
”; $(“#频率#u数据”)。追加(“在当月的最后一天
”; } 如果(所选==“5”){ $(“#频率数据”).empty(); $(“#频率数据”)。追加(“从开始日期(周一、周二等)起,每四周在一周的同一天,
”; } 如果(所选==“6”){ $(“#频率数据”).empty(); $(“#频率数据”)。追加(“月日
”; $(“#频率"数据”)。追加(“每月的第一个第二个第三个第四个星期日星期日星期二星期四星期五星期六
”; $(“#频率数据”)。追加(“在每个月的最后一天
”; } }); $(文档)。在('click','input[id^=“1”]”上,函数(){ $(“#radio1”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“2”]”上,函数(){ $(“#radio2”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“3”]”上,函数(){ $(“#radio5”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“4”]”上,函数(){ $(“#radio5”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“5”]”上,函数(){ $(“#radio6”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“6”]”上,函数(){ $(“#radio8”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“7”]”上,函数(){ $(“#radio8”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“8”]”上,函数(){ $(“#radio10”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“day_order”]”上,函数(){ $(“#radio9”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“day_name”]”上,函数(){ $(“#radio9”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“monthly_dropdown”]”上,函数(){ $(“#radio9”).prop(“选中”,为真) }); $(文档)。在('click','input[id^=“last\u day\u monthly”]”上,函数(){ $(“#radio10”).prop(“选中”,为真) }); /* $(“#事件”)。提交(函数(e){ //防止默认提交 警报(“调用了.submit()的处理程序”); e、 预防默认值(); //将“this”(匹配的表单)的数据发送到您的URL $.post($)http://www.hiu.edu/cms/events.php“,$(this.serialize()); }); */ });
鉴于该错误,有两种/三种可能性:

  • 页面的实时版本使用的jQuery版本比页面的开发版本旧。jQuery 1.7中添加了
    on
    方法

    解决方案:在开发和live中使用相同的版本(最好是最新版本)

  • 该页面的实时版本有PrototypeJS、MooTools或其他定义了
    $
    函数的东西,而不是jQuery

    解决方案:确保将jQuery放在页面上,并使用PrototypeJS/MooTools/处理任何冲突

  • 实时版本上有jQueryPrototypeJS、MooTools或类似内容,jQuery首先被加载,然后被PrototypeJS、MooTools或类似内容覆盖

    解决方案:了解如何使用
    noConflict


  • 检查jquery包含,确保live站点使用与开发人员相同的jquery版本。live页面上的jquery版本是什么?