20 lines
364 B
JavaScript
20 lines
364 B
JavaScript
export function ajax(url,data,type="post"){
|
|
return new Promise((resolve,reject)=>{
|
|
$.ajax({
|
|
url:url,
|
|
type:type,
|
|
dataType:"json",
|
|
data:JSON.stringify(data),
|
|
headers:{
|
|
"Content-Type":"application/json;charset=utf-8",
|
|
},
|
|
success:function(resData){
|
|
resolve(resData);
|
|
},
|
|
error:function(error){
|
|
reject(error);
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|