首页 > jquery

PHP jQuery ajax无刷新文件下载次数统计

本实例需要读者具备PHP、Mysql、jQuery以及html、css等相关的基本知识,在开发示例前,需要准备Mysql数据表,本文假设有一张文件下载表downloads,用来记录文件名、保存在文件服务器上的文件名以及下载次数,前提是假设下载表中已存在数据,这些数据可能来自项目中的后台上传文件时插入的,以便我们在页面中读取.

阅读全文

Codigniter框架PHP POST提交到两个地址实现

Codigniter框架使用jquery+ajax/" target="_blank">jquery ajax代码如下:

 <form action="<?php echo @htmlspecialchars($url['login_url']) ?>"  method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1">
        <p><label>工资号:</label>
            <input name="Login.Token1" class="text" type="text" id="token1" />
        </p>
        <p><label>密 码:</label>
            <input name="Login.Token2" class="text" type="password" id="token2" />
        </p>
        <p>
            <input name="登录" type="submit" id="user_login" value="登录" />
            <input type="reset" value="重置" />
        </p>
        <b style="color:red"><?php echo $this->session->flashdata('error'); ?></b>
    </form>
<script>
    $(function(){
        $("#user_login").click(function(){
            var username = $("#token1").val();
            var salary_no = $("#token2").val();
            $.ajax({
                type: "POST",
                data: "username="+username+"&salary_no="+salary_no,
                url: "<?php echo site_url('http://pic4.phprm.com/2013/05/07/ajax_check_username.jpg')?>",
                dataType: "text",
                cache: false,
                error: function(){alert('error');},
                success: function(data){
                    if(data == 'yes'){
                        location.href="<?php echo site_url('http://pic4.phprm.com/2013/05/07/index.jpg')?>";
                    }else{
                        form1.submit();
                    }
                }
            });
            return false;
        });
    });
</script>

阅读全文