I have one form with Jquery validation which is working perfectly, Even AJAX is also working perfectly if I use my validation code with AJAX on the same page.
Now What I did, I create a file called as validation.js and I added my validation code with AJAX in it and I added a script like below in my view page.
<script type="text/javascript" src="<?php echo base_url() ?>js/validation.js"></script>
Then I clicked on submit button It's checked my validation even it also goes to AJAX URL which I entered but this time I haven't got output.
I am getting in Network tab in the browser my URL like this
<?php echo base_url("index.php/user_control/admin_submit_from"); ?>
I am using sublime text editor If I used above URL on the same page then the base_url
color is showing in blue and If I used in validaion.js the color is showing in yellow.
Above URL Is not working from the validation.js file. Would you help me in this?
My Jquery validation with AJAX
$(document).ready(function() {
$("form[name='admin_form_submit']").validate({
rules: {
firstname: {
required: true,
minlength:3,
maxlength:50
},
lastname: {
required: true,
minlength:3,
maxlength:50
},
role:{
required: true
},
inst_name:{
required: true
}
},
submitHandler: function(form) {
//// form.submit();
$.ajax({
type: 'post',
url: '<?php echo base_url("index.php/user_control/admin_submit_from"); ?>',
data: $('form[name="admin_form_submit"]').serialize(),
success: function (data) {
alert(data);
}
});
}
})
});