看板 Web_Design 關於我們 聯絡資訊
好像可以,我無聊試了一下 東拼西湊醜了點 <html> <head> <script src="https://code.jquery.com/jquery-1.12.4.js" integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU=" crossorigin="anonymous"></script> <script> function fetchStatus(url) { $.ajax({ url: url, timeout: 2000, type: 'GET', crossDomain: true, dataType: 'jsonp', success: function() { alert("Success"); }, error: function(x, t, m) { if(t==="timeout") { alert('invalid'); } else { alert('valid'); } } }); } </script> </head> <body> <button onclick="fetchStatus('http://www.google.com')">Test1</button> <button onclick="fetchStatus('http://www.ggwrugkaawieughla.com')">Test2</button> </body> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.229.246.221 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1471277217.A.AF4.html
yongb: 謝謝大大~~ 08/16 19:41