首页 >php教程 >php手册 >Codigniter框架PHP POST提交到两个地址实现

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

WBOY
WBOY原创
2016-05-25 16:55:15894浏览
本文章结合Codigniter框架与jquery 的ajax实现PHP POST提交到两个地址实现代码,有需要了解的朋友可进入参考。

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

 代码如下 表>

ajax提交到home控制器代码:

复制代码
 代码如下 复制代码

 


       


           
       


       


           
       


       


           
           
       


        session->flashdata('error'); ?>
   

<script><br>    $(function(){<br>        $("#user_login").click(function(){<br>            var username = $("#token1").val();<br>            var salary_no = $("#token2").val();<br>            $.ajax({<br>                type: "POST",<br>                data: "username=" username "&salary_no=" salary_no,<br>                url: "<?php echo site_url('http://pic4.phprm.com/2013/05/07/ajax_check_username.jpg')?>",<br>                dataType: "text",<br>                cache: false,<br>                error: function(){alert('error');},<br>                success: function(data){<br>                    if(data == 'yes'){<br>                        location.href="<?php echo site_url('http://pic4.phprm.com/2013/05/07/index.jpg')?>";<br>                    }else{<br>                        form1.submit();<br>                    }<br>                }<br>            });<br>            return false;<br>        });<br>    });<br></script>

 

       


           
       


       

< ;label>密码:
           
        p>
       


           
           
       


        session-> flashdata('错误'); ?>
   

<script><br>    $(function(){<br>        $("#user_login").click(function (){<br>            var 用户名 = $("#token1").val();<br>            var salary_no = $("#token2").val();<br>            $.ajax({ <br>                输入:“POST”,<br>                数据:“username=”用户名“&salary_no=”salary_no,<br>                url:“<?php echo site_url('http://pic4.phprm. com/2013/05/07/ajax_check_username.jpg')?>",<br>                dataType: "text",<br>                缓存: false,<br>                错误: function(){alert('error ');},<br>                成功:函数(数据){<br>                    if(data == '是'){<br>                        location.href="<?php echo site_url('http:// /pic4.phprm.com/2013/05/07/index.jpg')?>";<br>                    }else{<br>                      form1.submit();<br>                    }<br>                } <br>            });<br>            返回 false;<br>        });<br>    });<br></script>

    # 提交到本地
    function ajax_check_username(){
 代码如下
 代码如下 复制代码


    #提交到本地
    function ajax_check_username(){
        //redirect('home/index');
        $username = $this->input->post("username");
        $salary_no = $this->input->post("salary_no");
        if($this->user_mdl->check_ajax_user($username,$salary_no)){
            $this->session->set_userdata('salary_no', $salary_no);
            $this->session->set_userdata('username', $username);
            echo "yes";
        }else{
            echo "no";
        }
    }

复制代码


        //redirect('home/index');        $username = $this- >input->post("用户名");        if($this->user_mdl->check_ajax_user ($username,$salary_no)){

            $this->session->set_userdata('salary_no', $salary_no);

            $this->session->set_userdata('username', $用户名);

            echo "是";

        }else{            echo "否";        }    } 论文地址:转载方便,但请附上文章地址:-)
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn