我正在嘗試使用ajax提交密碼更改,以便能夠在更改後保留在相同的ui.tab頁面上,並提供視覺反饋。 如果我在表單中留下action =「change_password_do.php」,那麼我可以更改密碼,這樣php文件就可以工作。如果我在表單中放置action =「」,我什麼也得不到。 顯然,在我的ajax中有一個基本的錯誤,但我無法找到它。有人能指點我嗎?ajax表單提交,我哪裏錯了?
<script type="text/javascript">
$(document).ready(function() {
$('#new_password_submit').click(function() {
$.ajax({
type: "POST",
url: "change_password_do.php",
data: $("form.pw_todo").serialize()
});
});
});
</script>
<div id="tabs_6" class="tabs">
<h2 class="tablecaption">Change your password</h2>
<form id="change_pass" class="pw_todo" method="post" action="">
<input class="formlogin" type="password" name="password1" placeholder="New Password" title="Type in your New Password"/><br />
<input class="formlogin" type="password" name="password2" placeholder="Re-enter New Password" title="Re-type your New Password"/><br />
<input type="submit" id="new_password_submit" value="Submit" class="button"/>
</form>
</div>
您是否包含jQuery?我沒有在你的代碼中看到它。 –
是的我已經包含jQuery –
縮進?你的意思是我沒有正確的開啓和關閉大括號? –