functioncallName() { let moi = 'Tsuifei'; console.log(moi); } callName(); // Tsuifei
在function裡的變數因為被函式包住,所以是區域變數,而在函式最外層的則是全域變數,所以在上面這段程式中,我們呼叫了callName()這個函式,再進去一行行執行函式內,當我們要它印出moi時,他會先去上面(已經讀到的)找,這時會找到let moi = 'Tsuifei';而把'Tsuifei'印出來。
Ajax 全名為 Asynchronous JavaScript and XML,一種允許瀏覽器與伺服器交換資料,而不需刷新頁面的技術,都可以叫做 Ajax.
Ajax 這個名字是在 2005 年 5 月的時候,Adaptive Path 的 Jasse James Garrett 在他所寫的文章 Ajax : New Approach to Web Application 中提出的。而 Ajax 這項技術,是由 Google 在 Google labs 發佈的 Google Maps 和 Google Suggest 後真正為人所認識。
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>; // 使用 GER 方法 // Make a request for a user with a given ID axios .get('/user?ID=12345') .then(function (response) { // handle success 接收伺服器的回應 console.log(response); }) .catch(function (error) { // handle error 如有錯誤會到這裡 console.error(error); }) .then(function () { // always executed 無論如何都會執行 }); // 使用 POST 方法