javascript - "Uncaught TypeError: object is not a function" when calling a function - Stack Overflow

I am having this odd error with my code. I am trying to troubleshoot a page that [used] to work in Chro

I am having this odd error with my code. I am trying to troubleshoot a page that [used] to work in Chrome but not in IE (suprise suprise) by adding specific triggers but now I am getting the Uncaught TypeError: object is not a function error in Chrome's console.

As far as I can tell this is a function (work in progress):

<script type="text/javascript">
    function validate() {                
            var id = jQuery("form").attr('id');
            var formid = "#"+id;
            jQuery(formid).add("<input type=\"hidden\" name=\"APC_UPLOAD_PROGRESS\" value=\""+id+"\" />");
            jQuery("#validate").hide();
            jQuery("#submitme").show();
    }
</script>

It is being called by the following code:

<button id="validate" onClick="validate()" type="button">Validate</button>

I am not using <input type="submit> as I have extra form submit JS to run.

So when I click the button the page does nothing and I get titular said error in the console.

I have tried using jQuery.fn.validate = function(){}; but to no avail.

To make this more interesting, the site is Wordpress and this particular page loads jQuery and MooTools as well as have straight JS.

In a nutshell; what silly little mistake have I made? All the searches on google are years old and generated by what I assume to be classes.

UPDATE

The console says this line is the error

<button id="validate" onClick="validate()" type="button">Validate</button>

UPDATE 2

Pastbin link to the form code

I am having this odd error with my code. I am trying to troubleshoot a page that [used] to work in Chrome but not in IE (suprise suprise) by adding specific triggers but now I am getting the Uncaught TypeError: object is not a function error in Chrome's console.

As far as I can tell this is a function (work in progress):

<script type="text/javascript">
    function validate() {                
            var id = jQuery("form").attr('id');
            var formid = "#"+id;
            jQuery(formid).add("<input type=\"hidden\" name=\"APC_UPLOAD_PROGRESS\" value=\""+id+"\" />");
            jQuery("#validate").hide();
            jQuery("#submitme").show();
    }
</script>

It is being called by the following code:

<button id="validate" onClick="validate()" type="button">Validate</button>

I am not using <input type="submit> as I have extra form submit JS to run.

So when I click the button the page does nothing and I get titular said error in the console.

I have tried using jQuery.fn.validate = function(){}; but to no avail.

To make this more interesting, the site is Wordpress and this particular page loads jQuery and MooTools as well as have straight JS.

In a nutshell; what silly little mistake have I made? All the searches on google are years old and generated by what I assume to be classes.

UPDATE

The console says this line is the error

<button id="validate" onClick="validate()" type="button">Validate</button>

UPDATE 2

Pastbin link to the form code http://pastebin./3Kw5vdhn

Share Improve this question edited May 23, 2012 at 4:56 Joshua asked May 23, 2012 at 4:00 JoshuaJoshua 1,1264 gold badges17 silver badges32 bronze badges 3
  • 1 The error console should show the line of the error. Which line causes the error? – nhahtdh Commented May 23, 2012 at 4:04
  • Sorry, I thought I put it in. This one ` <button id="validate" onClick="validate()" type="button">Validate</button> Uncaught TypeError: object is not a function ` will update OP. – Joshua Commented May 23, 2012 at 4:16
  • <script type="text/javascript" language="javascript"> try putting this . – Priyank Patel Commented May 23, 2012 at 4:31
Add a ment  | 

2 Answers 2

Reset to default 1

In the Chrome browser you can ask that JS execution stops at an exception. To enable that, open the JS console and click on the small icon to the left of the moustaches between the main panel and the console. If the icon is blue you will stop execution on all exceptions, if red only on uncaught exceptions and if it is gray no stop at all.

So click until it is red to stop on uncaught exceptions. Run your web-page and executon should stop EXACTLY at the point the exception is raised. Then you can examine the value of the validate variable.

I suspect it is some sort of global varaible clash between your code and other code you are loading. To check that quickly, rename validate something like QQvalidate and try your code.

Hi Joshua I tried running same code on my PC and its working perfectly, check your references (jQuery source file etc).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745230485a4617655.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信