首页 > Web开发 > 详细

使用jquery再次封装ajax

时间:2015-04-22 20:01:59      阅读:261      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!