JQuery 调用 Promise 状态改变与触发调用的记录
<html> <head> <title>Parcel Sandbox</title> <meta charset="UTF-8" /> <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script> </head> <body> <button id='btn'>Get Data</button> <script> function showError(e) { console.warn("Error", e); } function fail() { console.log("fail", arguments); } function success() { console.log("success", arguments); } function getUser(id) { return new Promise((a, b) => { if (id % 2 == 0) { a(654321); } else { b(123456); } }); } $("#btn").on("click", () => { getUser(666) //当then的