12 Star 37 Fork 12

郏高阳 / easy-ajax

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

**Team(郏高阳,赵长永) **

why easy-ajax

easy-ajax是为了治理前端乱写Ajax方法而生。基于jquery封装一些常用方法,后期计划加入前端数据缓存功能。

使用方法如下:

<script src="easy.ajax.js"></script>

API:

config配置项:

config{
    jqueryAjax默认配置外增加如下配置:
    mustCallback:强制回调(很多情况请求失败后直接在Ajax中提示后端返回的错误信息就结束了,不会进入回调函数,但很难避免失败也需要处理逻辑的情况,所以增加了此项配置,无论成功失败皆执行配置中的callback,前提是有回掉函数。)
}

使用from表单方式处理参数请求后台(接口使用@RequestParam时使用)

EasyAjax.post_form_json

使用普通方式请求(接口使用@RequestBody时使用)

EasyAjax.post_json

文件上传方法1:

var file = $(".xxx").get(0).files[0];
var fileData = new FormData();
fileData.append("file", file);
EasyAjax.ajax_Upload_File({
                    url: "URL",
                    data: fileData
                },
                function (data) {
                    if (data.success) {
                        //上传成功
                    }
                });

文件上传方法2:直接配置elem方法,使用方式如下:

EasyAjax.ajax_Upload_File_Elem({
                    url:"URL"
                    , elem: "#icon"
                },function (res) {
                    if (res.success) {
                        //上传成功
                    }
                });

有任何问题或者建议可以留言,大家一起努力为开源做一点小贡献。让开发更便捷,更易拓展!

The MIT License (MIT) Copyright (c) 2017 郏高阳 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.

简介

基于JQuery封装统一Ajax,是为了治理前端乱写Ajax方法而生。使用起来更方便便捷……统一ajax请求处理,统一动画加载等。 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/FakeMr/easy-ajax.git
git@gitee.com:FakeMr/easy-ajax.git
FakeMr
easy-ajax
easy-ajax
master

搜索帮助