Javascript JQuery error undefined不是函数
我正在我的一个组件中使用一小块javascript。在我的开发服务器上,它工作正常,但当我将其联机时,它会显示错误:Javascript JQuery error undefined不是函数,javascript,jquery,Javascript,Jquery,我正在我的一个组件中使用一小块javascript。在我的开发服务器上,它工作正常,但当我将其联机时,它会显示错误: Uncaught TypeError: undefined is not a function 第一行出现此错误: jQuery(".rdbookings_interval_grid").live('click', function() { 也许有人能给我一个线索 jQuery.noConflict(); jQuery(".rdbookings_interval_grid"
Uncaught TypeError: undefined is not a function
第一行出现此错误:
jQuery(".rdbookings_interval_grid").live('click', function() {
也许有人能给我一个线索
jQuery.noConflict();
jQuery(".rdbookings_interval_grid").live('click', function() {
// Get the id of the clicked item:
var interval = jQuery(this).attr("id");
// Get the active date:
var date= jQuery( "#wish_date" ).val();
var service = jQuery( "#service" ).val();
// Create AJAX data:
var data = 'date='+date+'&service='+service+'&interval='+interval;
jQuery.ajax({
url: "index.php?option=com_rdbookings&controller=jquery&task=bookInterval&format=raw",
//POST method is used
type: "POST",
//pass the data
data: data,
// data type = json
dataType: 'json',
//Do not cache the page
cache: false,
//success
beforeSend: function() {
jQuery( "#loader_date_picker" ).show();
jQuery( "#msg" ).hide();
},
success: function (html) {
// We're done, show data
jQuery( "#loader_date_picker" ).hide();
if(html.status != 666) {
// Update Reservations:
jQuery( '#reservations' ).html(html.msg);
// Update cart
updateCart();
// Update cart
updateGrid();
}else{
jQuery( "#msg" ).html(html.msg);
jQuery( "#msg" ).show();
}
},
});
});
当对象的方法不存在时,尝试调用对象的方法时,经常会遇到错误消息
uncaughttypeerror:undefined不是函数。这是因为Javascript方法调用实际上只是a)访问具有要调用的方法名称的对象的属性,b)假设返回的值是函数,并使用您认为需要的任何参数调用它。如果结果表明该值不是函数或未定义,则会出现错误
正如评论者所指出的,将live
更改为on
应该可以解决这个问题(即您一直在调用jQuery对象的live
方法),但如果仍然发生,请检查与错误消息相关联的行号。您还应该考虑您的过程,以确保您的开发环境始终反映您的代码可能部署的jQuery版本(以及其他库),以避免将来出现类似问题。尝试将live
更改为on
上的,如果可行,请告诉我。您使用的jQuery版本是什么?live
几年前从jQuery中删除<代码>实时
已删除。在