4 Star 4 Fork 1

无鞘之刃 / formJs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT
 _____                        _     
|  ___|__  _ __ _ __ ___     | |___
| |_ / _ \| '__| '_ ` _ \ _  | / __|
|  _| (_) | |  | | | | | | |_| \__ \
|_|  \___/|_|  |_| |_| |_|\___/|___/
                                    

一、简介

对html5DOM中的Form表单对象进行重写,使其可以使用ajax无刷技术和服务器进行数据交换。 1.0 版本无任何依赖,直接引入JS文件即可使用。

1.语法和API说明

语法说明:

var formObj = new FormJs(option);

formObj : 表示对象名 FormJs : 表示类名 option : 表示传入一个对象

例子:

var formObj = new FormJs({
	formId : "demoForm",
	isRefresh : false,
	async : false,
	subButId : "submitButton", 
	onclick : function(){
	   	alert();
	},
	callback : function(state,data,xhr,ts,errorinfo){
		if ( state == "success" ){
			console.log(data);
		}
	}
});

option说明:

option name intro
formId form元素的ID : 类型为字符串
isRefresh 是否采用无刷技术(如果设置为true,则会使用HTML5.0默认方式进行数据提交) : 类型为布尔值
async 是否采用异步,类型为布尔值
subButId form表单中作为提交事件触发的按钮的ID : 类型为字符串
onclick 请求前触发的回调函数
callback 提交后的回调函数,包含以下五个参数:
  1. state : 表示状态,字符串类型,包含(success,complete,error)分别代表(成功,完成,出错)
  2. data : 请求成功后服务器返回的数据,强制类型为字符串。
  3. xhr : 返回xhr对象
  4. ts: 返回xhr的状态
  5. errorinfo : 如果出现错误,则返回的错误信息
The MIT License (MIT) Copyright (c) 2016 无鞘之刃 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

对html dom 中的 form对象进行重写,使其可以使用ajax无刷技术和服务器进行数据交换。 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/lisniuse/formJs.git
git@gitee.com:lisniuse/formJs.git
lisniuse
formJs
formJs
master

搜索帮助