sudhakar phad sudhakar phad - 1 year ago 64
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?

Answer Source

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) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download