更新时间:2022-06-13 02:33:12
您可以使用Promises或回调来完成所需的操作.
You can use Promises or callbacks to accomplish what you want.
function write_csv(data, path, file, callback) {
$.ajax({
url: 'functions.php',
type: 'POST',
data: {
operation: 'SAVE_CSV',
save_path: path,
save_file: file,
save_string: data
},
success: function(result) {
console.log('write_file(' + path + file + '); -done');
callback(true); /* <-- */
}
});
}
并且:
function make_csv () {
/*
|
V
*/
function go_on() {
alert('YEAH!');
}
write_csv(my_data, my_path, 'export.csv', function(result) {
if (result == true) {
go_on();
}
});
}