forked from HANYANG/HANYANG_MES
77 lines
2.4 KiB
JavaScript
77 lines
2.4 KiB
JavaScript
var ajax_form = async function(conf){
|
|
|
|
await jQuery.ajax({
|
|
url: conf.url,
|
|
type: conf.type||'post',
|
|
data: conf.data, //formdata
|
|
contentType:false,
|
|
cache:false,
|
|
processData:false,
|
|
crossDomain: !!conf.curl,
|
|
dataType: conf.dataType||"json",
|
|
success:conf.success||function(){},
|
|
error:conf.error||function(){},
|
|
complete:conf.complete||function(){},
|
|
})/*.done(function(data){
|
|
return conf.success && conf.success(data);
|
|
}).fail(function(data){
|
|
return conf.error && conf.error(data);
|
|
})*/;
|
|
|
|
|
|
// fetch(conf.url, {
|
|
// method: conf.type||'POST',
|
|
// mode: 'cors', // no-cors, *cors, same-origin
|
|
// cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
|
// credentials: 'same-origin', // include, *same-origin, omit
|
|
// headers: {
|
|
// 'Content-Type': 'multipart/form-data',
|
|
// //'Content-Type': 'application/json',
|
|
// //'Content-Type': 'application/x-www-form-urlencoded',
|
|
// },
|
|
// redirect: 'follow', // manual, *follow, error
|
|
// referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
|
|
// body: conf.data, // body의 데이터 유형은 반드시 "Content-Type" 헤더와 일치해야 함
|
|
// })
|
|
// .then(response => conf.complete)
|
|
// .then(data => conf.success)
|
|
// .catch(error => conf.error);
|
|
};
|
|
|
|
var ajax_json = async function(conf){
|
|
|
|
await jQuery.ajax({
|
|
url: conf.url,
|
|
type: conf.type||'post',
|
|
data: conf.data, //json data
|
|
async: true,
|
|
crossDomain: !!conf.curl,
|
|
dataType: conf.dataType||"json",
|
|
success:conf.success||function(){},
|
|
error:conf.error||function(){},
|
|
complete:conf.complete||function(){},
|
|
})/*.done(function(data){
|
|
return conf.success && conf.success(data);
|
|
}).fail(function(data){
|
|
return conf.error && conf.error(data);
|
|
})*/;
|
|
};
|
|
|
|
var ajax_str = async function(conf){
|
|
|
|
await jQuery.ajax({
|
|
url: conf.url,
|
|
type: conf.type||'post',
|
|
data: conf.data, //querystring, stringfiy
|
|
contentType: "application/json; charset=utf-8",
|
|
crossDomain: !!conf.curl,
|
|
dataType: conf.dataType||"json",
|
|
success:conf.success||function(){},
|
|
error:conf.error||function(){},
|
|
complete:conf.complete||function(){},
|
|
})/*.done(function(data){
|
|
return conf.success && conf.success(data);
|
|
}).fail(function(data){
|
|
return conf.error && conf.error(data);
|
|
})*/;
|
|
}; |