var res = send("type", "123");
console.log(res);
function send(type, data) {
$.ajax({
method: "POST",
url: "send.php",
data: {
type: type,
data: data
},
success: function(result) {
return result;
},
});
}
function send(type, data, callback) {
$.ajax({
method: "POST",
url: "send.php",
data: {
type: type,
data: data
},
success: function(result) {
callback(null, result);
},
error: function(error) {
callback(error);
}
});
}
send("type", "123", (error, res) => {
if (error) {
console.error(error)
return undefined;
}
console.log(res);
});