I'm new to Jquery ajax, and I'm trying to submit certain field only for checking instead of submitting the whole form. Here I have made a function for checking the username whether is it available, and it works fine, but I doesn't want it to submit the whole form when doing the checking.
Here is my script:
<form id="userCheck">
<input type="text" class="register_field" name="fr_username" id="fr_username" />
<input type="text" class="register_field" name="fr_password" id="fr_password" />
<input type="text" class="register_field" name="fr_password1" id="fr_password1" />
</form>
<script>
$.validator.addMethod("duplicateCheck", function(value, element) {
$.ajax({
type: 'POST',
url: '../a/checkDuplicate',
data: $("#userCheck").serialize(),
dataType: 'json'
}).success(function(data){
if(data.status == '1'){
console.log('Available!');
}
else {
console.log('not available');
$('#fr_dupChkU_msg').html('');
}
});
});
</script>