2014-04-03 37 views
-5

我收到Uncaught TypeError:Object#在頁面的實時版本中沒有方法'on',但在測試頁上錯誤不顯示up ...我哪裏可能出錯?它有效並且不起作用?Uncaught TypeError:Object#<Object> has no method'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()); 
}); 
*/ 

}); 
+3

檢查你的jQuery包括,確保活的網站使用相同的jQuery版本作爲開發。 –

+3

活頁上有什麼jQuery版本? – tymeJV

回答

3

考慮到誤差,有兩種/三種可能性:

  1. 頁的現場版本使用大於頁面的開發版本的舊版本的jQuery。在jQuery 1.7中添加了on方法。

    解決方案:在開發和生活中使用相同的版本(最新的,理想的)。

  2. 頁的真人版有PrototypeJS,MooTools的,還是其他什麼東西定義就可以了$功能,而不是 jQuery的。

    解決方案:確保你在頁面上放置jQuery,並處理任何與PrototypeJS/MooTools /任何與noConflict衝突的任何衝突。

  3. 真人版擁有jQuery的 PrototypeJS,MooTools的,或者它類似,和jQuery是第一次加載,然後通過PrototypeJS,MooTools的,或類似的覆蓋。

    解決方案:看看如何使用noConflict

+1

優秀的答案,謝謝! – user3495710

相關問題