Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在发布一个表单 vi jQuery 的 $.post,这是我的代码:
function onSuccess() { // Do something onSuccess alert('yep'); } $('#createUserForm').submit( function(){ $.post("test.php", $(this).serialize(), onSuccess()) });
浏览器怎么会提示“是”然后重新加载页面?!
谢谢!
一方面:
$.post("test.php", $(this).serialize(), onSuccess); //<--remove the ()
二、禁用默认动作:
$('#createUserForm').submit( function(e){ e.preventDefault(); $.post("test.php", $(this).serialize(), onSuccess); return false; });