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

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

WBOY
Release: 2016-05-25 16:55:15
Original
902 people have browsed it
本文章结合Codigniter框架与jquery 的ajax实现PHP POST提交到两个地址实现代码,有需要了解的朋友可进入参考。

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

 代码如下 复制代码

 


       


           
       


       


           
       


       


           
           
       


        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>

ajax提交到home控制器代码:

 代码如下 复制代码


    #提交到本地
    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";
        }
    }



本文地址:

转载随意,但请附上文章地址:-)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template