drd2551 2014-11-25 12:36
浏览 41

Javascript:Undefined不是函数错误

I have a bit of javascript that I am trying to untangle, it's on a PHP form to calculate mortgage repayments, but clicking the calculate button does nothing.

Looking at Chrome Console I get the message

Uncaught TypeError: Undefined is not a function" on line 10($("#form_7") to 19

of the following code.

<script type="text/javascript">
    $(document).ready(function() {
        $("a.ActiveButton").bind({
            mousedown:function(){
                if ($(this).attr('disabled') === undefined ) 
                    $(this).addClass('Activated');
            }, 
            mouseleave:function(){ 
                if ($(this).attr('disabled') === undefined ) 
                    $(this).removeClass('Activated');
            }, 
            mouseup:function(){ 
                if ($(this).attr('disabled') === undefined ) 
                    $(this).removeClass('Activated');
            }
        });

        $("#form_7").validate({ 
            onkeyup: false, 
            showErrors: function(errorMap, errorList) { 
                if (errorList.length) alert(errorList[0].message); 
            }, 
            onclick: false, 
            rules: { 
                'Property_Price': { number: true } , 
                'Deposit': { number: true } , 
                'Duration': { number: true } , 
                'InterestRate': { number: true }  
            }, 
            onfocusout: false, 
            messages: { 
                'Property_Price': { number: "Please enter the property purchase price." } , 
                'Deposit': { number: "Please enter your deposit amount or 0 if there is no deposit." } , 
                'Duration': { number: "Please enter the duration of the mortgage." } , 
                'InterestRate': { number: "Please enter the mortgage interest rate." }  
            } 
        });

        $('#btn_4').click( function(){validate_form_7( form_7 )});
    });
</script>

Does anyone know what is causing this error and how it can resolved?

  • 写回答

2条回答 默认 最新

  • dongrao1862 2014-11-25 12:44
    关注

    The answer is that your code is trying to dereference as a function something, that isn't one.

    Try enabling stop-on-exception mode in your browser and see what "function" your code is trying to call when it crashes. Once you have a stack trace, it will be easier both for you to figure out, and for us to help.

    Off-hand, I do not see any issues with the provided code.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值