Php Codeigniter如何在响应后将值传递给ajax?

Php Codeigniter如何在响应后将值传递给ajax?,php,ajax,Php,Ajax,我是codeigniter的新手,现在在响应后将值传递给ajax时陷入了困境。我尝试在php检查后回显值,但当ajax响应显示所有html元素时,我只希望回显值仅来自php,请提供任何想法。这是我在控制器中的代码 public function index(){ //Fetch page template if(isset($_POST['email'])){ $this->data['email'] = $this->sign_up_m->ge

我是codeigniter的新手,现在在响应后将值传递给ajax时陷入了困境。我尝试在php检查后回显值,但当ajax响应显示所有html元素时,我只希望回显值仅来自php,请提供任何想法。这是我在控制器中的代码

public function index(){
    //Fetch page template
    if(isset($_POST['email'])){
        $this->data['email'] = $this->sign_up_m->get_by(array('email' => $_POST['email']), TRUE );
        if(empty($this->data['email'])){
            $this->sign_up_m->save(array('email' => $_POST['email'], 'date' => date('Y-m-d H:i:s')));
        }else{
            $this->data['email'] = $_POST['email'];
            echo'exist';
        }
    }
    $page = $this->uri->segment(1);
    if( is_null($page)){
        $page = 'home';
    }
    $this->data['home'] = $this->page_m->get_by(array('nice_name' => $page),TRUE);
    count($this->data['home']) || show_404(current_url());
    //Fetch page data
    $method = '_'. $this->data['home']->template;
    if(method_exists($this, $method))
    {
        $this->$method();
    }
    else
    {
        log_message('errors','Could not load template'. $method. 'in file'. __FILE__. 'at line'. __LINE__);
        show_error('Could not load template', $method);
    }
    $this->data['subview'] = $this->data['home']->template;
    $this->load->view('_layout_main', $this->data);
}
这是我的ajax

$('.sign_up').click(function(){
        var email = $('.email_signup').val();
        var validate = isValidEmailAddress(email);
        if(!isValidEmailAddress(email)){
            $('.invalide_email').css('display','inline');
            return;
        }
        $.ajax({
            type: 'post',
            url: 'http://localhost:8080/project/www.example.com/',
            data: {
                email: email,
            },
            beforeSend: function(){
                $('#load').css('display','inline');
            },
            success: function( response ) {
                $('#load').css('display','none');
                console.log(response);
            }
        });

    });

放置
exit()
die()在函数末尾,您将从该函数中回显此url的值。。。。r你确定这是正确的吗?Naincy,我工作正常,我只想在它响应时回显我想要的字符串,urfusion,我试过了,但不起作用urfusion,现在我解决了这个问题,感谢urfusion的想法,它在函数末尾不起作用,但在传导isset()中起作用