# Hi~前端工具們 - jQuery basic 3 ### 用 jQuery 發 request **jQuery 與 Ajax** 資源 https://restcountries.eu/ https://api.jquery.com/category/ajax/ http://youmightnotneedjquery.com/ **$.ajax()** 1. 先呼叫$.ajax() ``` <script> $.ajax({ method:'GET', url:'https://restcountries.eu/rest/v2/name/taiwan' }) ``` 參數可以傳物件,就可以指定細節,也可以只傳網址 送出 request 後,要拿到結果 2. 呼叫.done(),裡面傳一個 callback function ``` .done(function(data){ console.log(data) }); </script> ``` - 如果確定是要拿 JSON格式的話,也可以這樣寫 ``` $.getJSON('/my/url', function(data) { }); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up