如何讓連結延時幾秒後跳轉呢? 已解決
$('#real_submit').click(function () { $.ajax({ cache: true, type: "POST", url: "{:U('ajax_add_real')}", data: $('#real_form').serialize(), async: false, success: function (resp) { if (resp.status == 1) { $.toast(resp.message); setTimeout(function(){ location.href = resp.url; },2000); } else { $.toast(resp.info, "cancel"); } } }); });
PHP 用sleep http://www.w3school.com.cn/php/func_misc_sleep.asp
<?php
echo date('h:i:s') . "<br />";
//暫停 10 秒
sleep(10);
//重新開始
echo date('h:i:s');
?>