我有一个覆盖弹出窗体里面。该表单有一个按钮和一个文本框(想象像FB Like和Comment框)。与表单的每次交互都会触发通过PHP函数调用的MySQL DB插入。问题在于,点击按钮或注释(并按下键盘上的回车键)后,叠加层消失,主页面刷新。我不希望发生这种情况,我想把重点放在弹出窗口上。我怎样才能做到这一点?提交表单后,如何关注重叠弹出窗口?
下面是一些代码:
<div id="LikeAndComment">
<form name="formLAC" method="post" action="">
<div id="containerLike">
<button type="submit" id="likeit" value="FALSE" onClick="{vote(); keepFocus();}">
<img src="images/implike_BUTTON.jpg" "/>
</button>
</div>
<div id="containerComment">
Commenta: <input type="text" class="input" id="comment" onkeydown="if (event.keyCode == 13) { this.form.submit(); keepfocus(); return false; }"></input>
</div>
</form>
</div>
而这里的keepFocus函数的代码:
function keepFocus() {
$('.formLAC').focus();
};
该页面将因为表单提交的被刷新。为了避免它 - 使用ajax。 – k102