【发布时间】:2015-12-05 18:28:36
【问题描述】:
我想在进行这个 ajax 调用后返回 true 或 false:
function write_csv(data, path, file) {
$.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');
return true; /* <-- */
}
});
}
我想要的示例用例:
function make_csv () {
/*
|
V
*/
if (write_csv(my_data, my_path, 'export.csv') == true) {
go_on();
}
function go_on() {
alert('YEAH!');
}
}
我知道它是异步的,但也许有人有其他想法。
我不会用 if 之类的东西来做这件事......
【问题讨论】:
标签: javascript jquery ajax asynchronous return