简体   繁体   English

通过jQuery(Javascript)提交表单失败

[英]Submitting form via jQuery (Javascript) failing

What am I missing here? 我在这里错过了什么? If I try to submit the form via javascript it doesn't work. 如果我尝试通过javascript提交表单,它不起作用。

Error (submitting with a regular JS reference and jQuery reference returns the same error) 错误(使用常规JS引用和jQuery引用提交返回相同的错误)

 SCRIPT3: Member not found.

Code: 码:

<a href="#" onclick="refresh_customer_data();return false;">Refresh customer data</a>
<script type="text/javascript">
function refresh_customer_data()
{
    $("#post-form").attr("action", "../scripts/refresh-customer-data.asp");
    $("#post-form").submit();
}
 </script>
<form method="post" action="" id="post-form">
<input type="hidden" name="fromsubmit" value="true" />
<table class="form" style="height:50px;">
<tfoot>
            <tr>
                <td><span class="required">*</span> Accessible by administrators only</td>
                <td><input type="submit" name="submit" value="" style="display:none;" /></td>
            </tr>  
</tfoot>
</table>
</form>  

Thanks! 谢谢!

Instead of inline calling the function, why not use jQuery to do it for you: 而不是内联调用函数,为什么不使用jQuery为您执行:

http://jsfiddle.net/8XdwS/ http://jsfiddle.net/8XdwS/

Why not use jQuery post to send your data to server page like this 为什么不使用jQuery post将数据发送到这样的服务器页面

<a href="#" id="aRefresh">Refresh customer data</a>

Javascript: 使用Javascript:

$(function(){
  $("#aRefresh").click(function(e){
    e.preventDefault();
    $.post("../scripts/refresh-customer-data.asp", $("#post-form").serialize(),function(data){
        //do whatever with the response from server page
      })     
    });
  });

I know this is an old thread but for everybody's information: 我知道这是一个旧线程但是对于每个人的信息:

I have come across this issue as well, and the problem was having the submit button named submit. 我也遇到过这个问题,问题是提交按钮名为submit。

Renaming the submit button ie. 重命名提交按钮即。 to submit2 solved the issue. 提交2解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM