ah_sz_gqj/src/main/resources/static/js/ajaxRequest.js

35 lines
850 B
JavaScript
Raw Normal View History

2024-07-17 09:44:55 +08:00
// ajax 请求封装
function ajaxRequest(url, type, data, async, beforeFn, successFn, errorFn, contentType) {
$.ajax({
url: url,
type: type,
headers: {
"token": tokens
},
data: data,
async: async,
beforeSend: beforeFn,
contentType: contentType || "application/x-www-form-urlencoded; charset=utf-8",
success: successFn,
error: errorFn
});
}
// 文件上传
function ajaxRequest2(url, type, data, beforeFn, successFn, errorFn) {
$.ajax({
url: url,
type: type,
data: data,
headers: {
"token": tokens
},
async:true,
dataType: 'json',
processData: false,
contentType: false,
beforeSend: beforeFn,
success: successFn,
error: errorFn
});
}