admin管理员组文章数量:1415664
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
2 Answers
Reset to default 1In 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).
本文标签: javascriptquotUncaught TypeError object is not a functionquot when calling a functionStack Overflow
版权声明:本文标题:javascript - "Uncaught TypeError: object is not a function" when calling a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745230484a2648801.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论