未捕获的TypeError:对象#< HTMLFormElement>的属性“提交";不是功能 [英] Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function

查看:97
本文介绍了未捕获的TypeError:对象#< HTMLFormElement>的属性“提交";不是功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该类型设置为提交",但仍然无法正常工作.我正在使用console.log,但是什么也没显示.我希望控制台日志显示一个数字(两个通过ajax加在一起)

The type is set as 'submit' but it is still not working. I'm using console.log but that doesn't display anything. I'd like the console log to display a number (two added together via ajax)

我该如何解决?

jQuery代码:

jQuery(document).ready( function($) {
(function($) {
$(document).ready(function(){
  $('#formsubmit').submit(function(){
  $.post(
  PT_Ajax.ajaxurl,
        {
       action : 'ajax-inputtitleSubmit',
       noofwelds : $('input[name=numberofwelds]').val(),
       noofconwelds : $('input[name=numberofconwelds]').val(),
       nextNonce : PT_Ajax.nextNonce
        },
  function( response ) {
     console.log( response );
        }
        );
      return false;
}); 

});
})(jQuery);
}); 

表格

<form action="" method="post" type="submit" name="formsubmit" id="formsubmit"   >
<h1> Process </h1>
<p> operation type always robot </p>
<br> <br>
Number of welds: <input type="number" name="numberofwelds" id="numberofwelds"  >
<br> <br>
Number of construction welds: <input type="number" name="numberofconwelds" id="numberofconwelds"  >
<br> <br>
Total one: <input type="text" name="totalone" id="totalone" disabled>
<div id="totalfail1"></div>
<br> <br> 
Total two: <input type="text" name="totaltwo" id="totaltwo" disabled>
<div id="totalfail2"></div>
<br> <br> <br> <br>
Total three: <input type="text" name="totalthree" id="totalthree" disabled>
<div id="totalfail3"></div>
<br> <br> <br> <br>
<input type="submit"  value="Calculate" id="formsubmit" name="submit" class="ajax-link" >
<div id="result"> </div>
</form> 

推荐答案

这是因为您的表单中有一个名称为submitinput元素,因此将其重命名

It is because you have an input element with name submit in your form, rename it

<input type="submit"  value="Calculate" id="formsubmit" name="formsubmit" class="ajax-link" >

这篇关于未捕获的TypeError:对象#&lt; HTMLFormElement&gt;的属性“提交";不是功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆