Ajax自动表单提交 [英] Ajax auto form submit

查看:118
本文介绍了Ajax自动表单提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何通过AJAX自动提交表单,而不必显式地点击提交按钮。



例如,假设我有以下表单:

 < form id =form1method =postaction =name =form1> 

行:< input type =textname =rowsid =rows/> < br />

列< input type =textname =columnsid =columns> <峰; br />

< / form>

当用户填写列文本框时,我希望提交表单。
我知道如何使用AJAX,但我希望它在列上的keyup事件上触发。

要在列输入上使用OnChange事件。也许确保行也填写有效数据,然后触发Ajax调用。



喜欢:

<$ p ($ {$ b $。$ j $($ $ $ $ $ $ $$ input $# :'post',
url:$(#form1)。attr('action')
etc etc
})
})


Does anyone know how to automatically submit a form via AJAX, without, having to explicitly click on the submit button.

For example, say I have the following form:

<form id="form1" method="post" action="" name="form1">

Rows: <input type="text" name="rows" id="rows" /> <br/ >

Columns<input type="text" name="columns" id="columns"> <br/>

</form>

When the user fills in the columns textbox I want the form to be submitted. I know how to use AJAX, but I want it triggered on keyup event on columns.

解决方案

Best way would be to make use of the OnChange event on the Columns input. Perhaps make sure rows is also filled out with valid data, then trigger the Ajax call.

Like:

$("input#columns").change(function() {
// if rows is filled out {
$.ajax({
type: 'post',
url: $("#form1").attr('action')
etc etc
})
})

这篇关于Ajax自动表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆