javascript - Ajax call url in an external js file -
i have web page (written in php / codeigniter) uses javascript code. i tried move javascript code external file better manage code. in document ready event load external file $.getscript('<?php echo base_url();?>assets/js/offerta_editscontirow.js'); one piece of code, putted in external js file, not work; instead works correctly if put code inside main php file. $.ajax({ datatype: 'json', url: '<?php echo site_url("offerta/applica_sconti");?>', cache: false, data: data, success: function (data, status, xhr) { ........ it not work because not elaborate php code, , in query string find "php echo site_url("offerta/applica_sconti");?>:" so, there way have works? may pass parameter external js file while loading it, , pass url used in ajax call? other method? kind regards, matt try window.my_url = 'some value...