如何让链接延时几秒后跳转呢? 已解决

 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');

?>

猜你喜欢

转载自blog.csdn.net/qq_35458793/article/details/71703624
今日推荐