我想在第一个 ajax 调用完成后运行函数“saveToFile()”,然后在完成后运行第二个 ajax 调用。似乎不像编码那样工作。我对 ajax 还很陌生,所以在这方面有点挣扎。
// save composition to database
$.ajax({
type: "POST",
url: "_inc/save_to_db.php",
data: {jsonStr: canvasStr},
success: function(data) {
// this saves the comp to the _comps folder on the server as a jpeg file (firth.js)
saveToFile();
$.ajax({
type: "POST".
url: "_inc/generate_thumbnail.php",
data: {imgFile: "<?php echo $_SESSION['UserID'] ?>_<?php echo $_SESSION['CompID'] ?>.jpg"},
});
}
});