Tom
Tom

Reputation: 4577

Submitting form via jQuery (Javascript) failing

What am I missing here? If I try to submit the form via javascript it doesn't work.

Error (submitting with a regular JS reference and jQuery reference returns the same error)

 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!

Upvotes: 1

Views: 1131

Answers (3)

Peter
Peter

Reputation: 775

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.

Renaming the submit button ie. to submit2 solved the issue.

Upvotes: 1

Shyju
Shyju

Reputation: 218702

Why not use jQuery post to send your data to server page like this

<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
      })     
    });
  });

Upvotes: 1

Lowkase
Lowkase

Reputation: 5699

Instead of inline calling the function, why not use jQuery to do it for you:

http://jsfiddle.net/8XdwS/

Upvotes: 1

Related Questions