码迷,mamicode.com
首页 > Web开发 > 详细

使用jquery再次封装ajax

时间:2015-04-22 20:02:12      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

 $.fn.ajaxSend = function (type, url, postdata, onSuccess) {
        $.ajax({
            async: false,
            url: url,
            type: type,
            data: postdata == null|| postdata == "" ? "" : postdata,
            datatype: "json",
            cache: false,
            contentType: "application/json; charset=utf-8",
            complete: $.OnAjaxComplete,
            success: function (data) {
                onSuccess(data);
            },
            error: $.OnAjaxError
        });
    };

  使用方法:

function postTest() {
        $(this).ajaxSend("post", "/ajaxTest1.ashx", "", function (res) {
            alert(res);
        });
    }

  

使用jquery再次封装ajax

标签:

原文地址:http://www.cnblogs.com/myblogslh/p/4448309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!