1

我在这里想念什么?如果我尝试通过 javascript 提交表单,它不起作用。

错误(使用常规 JS 引用和 jQuery 引用提交返回相同的错误)

 SCRIPT3: Member not found.

代码:

<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>  

谢谢!

4

3 回答 3

1

与其内联调用函数,不如使用 jQuery 为您完成:

http://jsfiddle.net/8XdwS/

于 2012-05-14T17:21:38.413 回答
1

为什么不使用 jQuery post 将您的数据发送到这样的服务器页面

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

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
      })     
    });
  });
于 2012-05-14T17:27:07.400 回答
1

我知道这是一个旧线程,但供大家参考:

我也遇到过这个问题,问题是提交按钮名为submit。

重命名提交按钮,即。提交2解决了这个问题。

于 2014-07-01T14:55:49.420 回答