Ajax 抽象方法和请求

obz.ajaxJson = function(url, param, callback, failureCallback) {
    $.ajax({
        url: url,
        data: param,
        type: "POST",
        traditional:true,
        beforeSend: function () {
        },
        success: function (data) {
           if (data.Success==undefined) {
              //兼容 IE
               data = $.parseJSON(data);
           }
            if (data.Success) {
                if (callback != undefined) callback(data);
            } else {
               if(failureCallback != undefined){
                 failureCallback();
              }
               //验证拦截器使用,把错误信息显示在前台
              for(var key in data){
                 //$("#"+key).text(data[key]);
                 $("#"+key).addClass("has-error");
                 $("#"+key).find("label").text(data[key]);
              }
           }
        },
        error: function (request) {
            if (failureCallback != undefined) failureCallback();
            else {
               if(typeof request != 'undefined' && request){
                  if(request.response){
                     alert(request.response);
                  }else{
                     alert("服务端没有响应,请联系客服......");
                  }
                  location.href = obz.ctx;
               }
            }
        }
    });
};

obz.ajaxJson(obz.ctx + "/attachment/delIds", {ids: values}, function(resp){
    console.info(resp);
    if(resp.code==200){
        searchImg();
    }
});