奇怪的问题,我必须在第一次双击提交我的表格,但在第一次之后,表格在一次点击后提交!
这是我的jquery:
<script type="text/javascript">
$(document).ready(function() {
var options = {
target: '.error_box_wrapper',
success: showResponse
};
// bind form using 'ajaxForm'
$('#edit_group_form').live('submit', function() {
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$(this).ajaxForm(options);
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false;
});
});
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
$("#leftside div#groups_container").load('includes/my_groups.php');
}
</script>
这是我的表格:
echo "<form id='edit_group_form' action='processforms/process_groups.php' method='POST'>";
echo "<input name='groupid' type='hidden' value='$groupid' />";
echo "<input name='image' type='hidden' value='$image' />";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='50000000' />";
echo "<table border=0 width=100%' style='border-left-width: 3px;border-left-style: solid;border-left-color: #ccc; margin-bottom:5px;' class='small_text' >";
echo "<tr><td valign=top align=right NOWRAP>Group Message:</td>";
echo "<td valign=top align=left><textarea name='groupmessage' cols=32 rows='3'>$groupmessage</textarea></td></tr>";
echo "<tr><td valign=top align=right NOWRAP>Group Name:</td><td valign=top align=left><input name='groupname' size='40' value=\"$groupname\"></td></tr>";
echo "<tr><td valign=top align=right NOWRAP>Group picture:</td><td valign=top align=left><input name='uploadedfile' type='file' /></td></tr>";
echo "</table>";
echo "<input type='submit' value='Save' name='submit_edit_group_form'/></td><td align=left><a href='?view=mygroups' class='mybutton' id='cancel_link'><b>Cancel</b></a>";
echo "</form>";
认为它可能与.live
有关非常感谢任何想法。谢谢
答案 0 :(得分:3)
而不是ajaxForm更改为ajaxSubmit。 AjaxForm将表单初始化为ajax表单,这就是为什么你必须再次点击它。
从我记得ajaxSubmit使用与ajaxForm相同的参数,所以你应该能够交换它。