学习-【前端】-ajax封装
平时我们多用ajax请求数据,这里给一个封装让大家参考下
function ajax(data, callback) { var defaultconifg = { "url": weburl, "contentType": "charset=UTF-8", "dataType": "json", "timeout": "400000", "beforeSend": loadAnimationOn, "type": "post" }; var succhandler = { "success": function(mess) { loadAnimationOff(); if (mess.resCode != 0) { alertInfo(mess.resMsg, '失败') } else { callback(mess); } } } var postdata = $.extend(defaultconifg, data, succhandler); $.ajax(postdata); }