Welcome Guest, Not a member yet? Register   Sign In
External Javascript
#1

Hi,
I am using CI4

My preferred way of using javascript/jquery is to use external .js files

Code:
<script src="<?php echo base_url('includes/common/js/myfunctions.js'); ?>" ></script>


rather than including the javascript/jquery in the page
Code:
$.ajax({
    type: "POST",
    processData: false, // important
    contentType: false, // important
    data: data,
    url: "<?= base_url('file/function'); ?>",
    dataType: "script",
    beforeSend: function() {
        $('.processing').show();
    },
    complete: function() {
        $('.processing').hide();
    },
    success: function (data) {
        alert(data);            
    },
    error: function(data) {
        alert('error '+data);
    },
});
Does codeigniter 4 address any of the obvious issues that would arise is if I was to use try and use codeigniter helpers like base_url() in an external js file???
Reply


Messages In This Thread
External Javascript - by 68thorby68 - 05-31-2020, 05:52 AM
RE: External Javascript - by mjamilasfihani - 06-01-2020, 02:21 AM
RE: External Javascript - by dave friend - 06-01-2020, 08:31 AM
RE: External Javascript - by 68thorby68 - 06-06-2020, 01:58 AM
RE: External Javascript - by InsiteFX - 06-06-2020, 03:35 AM
RE: External Javascript - by 68thorby68 - 06-09-2020, 06:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB