| 123456789101112131415161718192021222324252627282930313233 |
- $(document).ready(function() {
- var options = {
- //target: '#output1', // 用服务器返回的数据 更新 id为output1的内容.
- beforeSubmit: showRequest, // 提交前
- success: showResponse, // 提交后
- //另外的一些属性:
- //url: url // 默认是form的action,如果写的话,会覆盖from的action.
- //type: type // 默认是form的method,如果写的话,会覆盖from的method.('get' or 'post').
- //dataType: null // 'xml', 'script', or 'json' (接受服务端返回的类型.)
- //clearForm: true // 成功提交后,清除所有的表单元素的值.
- resetForm: false // 成功提交后,重置所有的表单元素的值.
- //由于某种原因,提交陷入无限等待之中,timeout参数就是用来限制请求的时间,
- //当请求大于3秒后,跳出请求.
- //timeout: 3000
- };
- //alert("=============") ;
- //'ajaxForm' 方式的表单 .
- $('#f1-form').ajaxForm(options);
- //或者 'ajaxSubmit' 方式的提交.
- //$('#myForm').submit(function() {
- // $(this).ajaxSubmit(options);
- // return false; //来阻止浏览器提交.
- //});
- });
-
- // 提交前
- function showRequest(formData, jqForm, options) {
-
- }
- // 提交后
- function showResponse(responseText, statusText) {
- $("#f1formmsg").html(responseText);
- }
|