當我提交下面的表單時,刷新當前頁面並將表單參數追加到頁面URL的末尾。爲什麼會發生這種情況?我需要提交表單,但隱藏了表單參數。jQuery表單提交
感謝
<div class="ui-block-b"><button id="submit" type="submit">Submit</button></div>
$("#submit").click(function(){
var formData = $("#newPostForm").serialize();
$.ajax({
type: "POST",
url: "/mobile/newpost.php",
cache: false,
data: formData,
success: onSuccess
});
return false;
});
將按鈕類型從'type =「submit」'更改爲'type =「button」',它不會刷新頁面。 – 2011-05-16 09:44:55