jquery-ajax增删改查

34次阅读

共计 1544 个字符,预计需要花费 4 分钟才能阅读完成。

var getvideosbatchpush = function(para){return new Promise(function(resolve, reject){
        $.ajax({
            url: "/v1/pingan/videos-batch-push",
            type: "GET",
            // dataType: 'jsonp',
            contentType: "application/json",
            data: para || {},
            success: function(resp, status, xhr){if(resp.status == "OK"){resolve(resp);
                }else{reject(resp);
                }
            },
            error: function(xhr, errorType, error){Notify.fail("网络开小差了,请稍后再试");
            }
        });
  });
};
var deletevideosbatchpush = function(para){return new Promise(function(resolve, reject){
        $.ajax({
            url: "/v1/pingan/videos-batch-push/" + para.id,
            type: "DELETE",
            // dataType: 'jsonp',
            contentType: "application/json",
            data: JSON.stringify(para || {}),
            success: function(resp, status, xhr){if(resp.status == "OK"){resolve(resp);
                }else{reject(resp);
                }
            },
            error: function(xhr, errorType, error){Notify.fail("网络开小差了,请稍后再试");
            },
        });
  });
};
var savevideosbatchpush = function(para){return new Promise(function(resolve, reject){
        $.ajax({
            url: "/v1/pingan/videos-batch-push",
            type: "POST",
            // dataType: "jsonp",
            contentType: "application/json",        
            data: JSON.stringify(para || {}),
            success: function(resp, status, xhr){if(resp.status == "OK"){resolve(resp);
                } else{reject(resp);
                }
            },
            error: function(xhr, errorType, error){Notify.fail("网络开小差了,请稍后再试");
            },
        });
  });
};
var putvideosbatchpush = function(para){return new Promise(function(resolve, reject){
        var id = para.id;
        var url = "/v1/pingan/videos-batch-push/" + id;
        $.ajax({
            url: url,
            type: "PUT",
            // dataType: 'jsonp',
            contentType: "application/json",
            data: JSON.stringify(para || {}),
            success: function(resp, status, xhr){if(resp.status == "OK"){resolve(resp);
                } else{reject(resp);
                }
            },
            error: function(xhr, errorType, error){Notify.fail("网络开小差了,请稍后再试");
            }
        });
  });
};

正文完
 0