js 用 setTimeout 引用当初做的项目一个实例
$('#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');
?>