sudhakar phad sudhakar phad - 7 months ago 22
jQuery Question

is it ok to write Javascript or jQuery code as a PHP file in CodeIgniter views?

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:

url: "<?php echo base_url('loginpage'); ?>",
type: 'POST',
data: {emailId:email1,password:pwd1},
success: function(result){

Is this OK?


It is perfectly alright , I am using this in a professional project

 var base_url = '<?php echo base_url(); ?>';

        var id = $('#searchCategory').val();
            type: "POST",
            url: base_url+"home/getSubCategory",
            data: {id:id},
            success: function(data) {