jquery ajax form validation not working with GET method codeigniter

TaraGurung

I have a form where I am checking the username is unique using the jquery ajax. It's working fine but the problem is when I use the GET method , it's returning me the same value again and again . The else statement is not running. It's working absolutely fine with POST method.

Here is the form with my jquery ajax implemented

<script type="text/javascript" src="<?php echo base_url('javascript/script.js');?>"></script>
<script>
$(document).ready(function(){

$("#username").change(function(e){

    $.ajax({
    url:'http://localhost/rental/index.php/members/ajaxVerify',
    type:'POST',
    data:{name:$(this).val()},
    success:function(data){

    $("#error_msg").html(data);
    $("#username").val('');

    }

    //ok will do that verify chaina bhane submit button unclickable banaidimla ...text delete garnu ko sato ....
    }); 

    });
});
</script>
<form method="post" action="<?php echo site_url('members/signupAdd');?>">
<table>
<tr><td>username:</td><td><input type="text" name="username" id="username"></td><td id="error_msg"></td></tr>
<tr><td>email:</td><td><input type="text" name="email" id="email"></td></tr>

<tr><td><input type="submit" name="submit" value="signup"></td></tr>
</table>

</form>

..Here is the model...

function uniqueName($typedname){
        $this->db->where('username',$typedname);
        $query=$this->db->get('users');
        if($query->num_rows>0)
        {
            return true;
        }
        else{
            return false;
        }
    }

And this is the controller..

function ajaxVerify(){
        $typedname=$this->input->post('name');

        //call model to verify unique username
        if($this->members_model->uniqueName($typedname))
        {
            echo "Username already exist";

        }
        else{
            echo '';    
        }   
    }
MH2K9

If you use type:'GET' in ajax then you should use in ajaxVerify() like this

$this->input->get('name');

And if you use type:'POST' then

$this->input->post('name');

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

jQuery validation not working with that form

분류에서Dev

form_validation CodeIgniter

분류에서Dev

Ajax Form Begin is not going to http GET method

분류에서Dev

Form action not working in codeigniter

분류에서Dev

Jquery Form Validation

분류에서Dev

Form validation Jquery no error

분류에서Dev

Express: jQuery Validation not working

분류에서Dev

AJAX not submitting the form after validation

분류에서Dev

Method Post and Get In CodeIgniter

분류에서Dev

before_validation method not working

분류에서Dev

url in jquery ajax post in codeigniter

분류에서Dev

jquery validation is not working with validate plugin

분류에서Dev

jQuery/AJAX Submit after Validation

분류에서Dev

Login with jQuery AJAX is not working

분류에서Dev

Using PHP form validation on jQuery form submission

분류에서Dev

codeigniter form_validation과 함께 post () jquery 메서드를 사용하는 방법

분류에서Dev

Validation isn't working for me for a bootstrap form

분류에서Dev

AJAX validation fails for all form data

분류에서Dev

false를 반환하는 codeigniter form_validation

분류에서Dev

Ajax form submission on a form created using jquery

분류에서Dev

remove validation zend form element javascript/jquery

분류에서Dev

jQuery validation: form always valid issue

분류에서Dev

jquery form validation for dynamic radio groups

분류에서Dev

Trigger jquery form validation if field is autofilled by browser

분류에서Dev

JQuery Raty And Angular - Adding form validation

분류에서Dev

Write rules in jquery-validation for Rails form

분류에서Dev

Enable button using jQuery ajax with CodeIgniter

분류에서Dev

codeigniter에서 jquery ajax 호출

분류에서Dev

Codeigniter & Jquery Ajax, Post data not going through

Related 관련 기사

뜨겁다태그

보관