I have created a JavaScript file as a PHP file in my CodeIgniter views so that I can access some of my PHP dynamic variable in JavaScript.
For example:
$.ajax({
url: "<?php echo base_url('loginpage'); ?>",
type: 'POST',
data: {emailId:email1,password:pwd1},
success: function(result){
Is this OK?