ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

ajax check members available not work

September 30, 2013 12:39am

Subscribe [1]
  • #16 / Oct 02, 2013 2:58am

    My last try
    Controller:

    class Your_controller extends CI_Controller {
    public function ajax_checklogin() {
            $login = $this->input->post('login', TRUE);
            if (!$this->user_model->if_exists(array('login' => $login))) {
                echo 'Free';
                return FALSE;
            }
            echo 'Taken';
            return FALSE;
        }
    }

    View:

    $.post("<?php echo base_url()?>your_controller/ajax_checklogin", { login: $("#selector").val() })
                            .done(function(data) {
                        $("#otherselector").html(data);
                    });

    user_model->ajax_checklogin returns true if exists, false if not.

  • #17 / Oct 02, 2013 4:14am

    Why Me

    10 posts

    hello bro

    i try to used get and working good but if change to type post not work

    code for type GET
    temp => controller

    class Your_controller extends CI_Controller {
        
        public function test_ajax()
        {
            $this->load->view('view_user');
        }
        public function info_page()
        {
             if  ($this->input->get('name', TRUE)){
                  echo $this->input->get('name', TRUE); 
             }
             else {
                 echo "Error";
             }
        }
     
    }

    temp = > view

    <html>
       <head>
          <title>Testing Ajax</title>
          [removed][removed]
          [removed]
                var base_url =  "<?php echo base_url(); ?>" ; 
                $(document).ready(function(){
                $('#gebutton').click(function(){
                $.get(base_url+'your_controller/info_page',{name:'My Name.!'},function(data){
                alert(data);
               });
             });
           });
    [removed]
       </head>  
          <body>
                  <button  class="sub"id="gebutton">Getname</button>
          </body>
    </html>

    if used type post have error
    “NetworkError: 500 Internal Server Error - http://localhost/mycode/your_controller/info_page

    you think a problem from config my loclalhost or config codeigniter?

  • #18 / Oct 02, 2013 4:25am

    Both post and get works flawlessly on my local enviroment. No idea what might be wrong in yours tho.

    Wild guess, swap
    {name:'My Name.!'}
    to
    { name: "My Name.!" },
    Also what response exactly do you get in firebug?

  • #19 / Oct 02, 2013 4:49am

    Why Me

    10 posts

    Both post and get works flawlessly on my local enviroment. No idea what might be wrong in yours tho.

    Wild guess, swap
    {name:'My Name.!'}
    to
    { name: "My Name.!" },
    Also what response exactly do you get in firebug?

    error

    SyntaxError: illegal character

    ...t(base_url+‘your_controller/info_page’,{ name: “My Name.!” },function(data)

     

  • #20 / Oct 02, 2013 7:17am

    Why Me

    10 posts

    Hello

    i Solved

    I change $config[‘csrf_protection’] = TRUE;  to $config[‘csrf_protection’] = FALSE; 

    everything now fine

    thank alot noideawhattotypehere

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases