我有一個小表單和一個鏈接,使用jQuery和POST提交此表單。我希望在不使用AJAX刷新的情況下在表單頁面上顯示流程頁面的HTML輸出。但是,當我點擊我的提交鏈接時,我的代碼似乎不起作用。請有人指出我在這裏可能做錯了什麼?非常感謝。使用鏈接提交表單在jQuery中將不起作用
問候
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#myform').submit(function() {
$.post('demoprocess.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
});
});
});
</script>
<form name="myform" id="myform" action="" method="POST">
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value=""/><br>>
<label for="email" id="email_label">Email</label>
<input type="text" name="email" id="email" size="30" value=""/><br>
<a href="#" title="" class="pay-button" style="margin-top:5px;" onclick="document.myform.submit()">SUBMIT</a>
</form>
<!-- We will output the results from demoprocess.php here -->
<div id="results"><div>
試''SUBMIT你 – 2012-01-11 14:02:58
代碼缺少'});'收了'document.ready'處理程序。這是一個錯字嗎?如果不是這可能會導致問題。 – 2012-01-11 14:04:04
謝謝Rory,有一個錯字,但它仍然不起作用 – user1038814 2012-01-11 14:15:24