Welcome Guest, Not a member yet? Register   Sign In
[Solved] Setting url in a .js file
#3

(This post was last modified: 11-02-2016, 03:17 AM by wolfgang1983.)

(11-01-2016, 10:45 PM)salain Wrote: As a work around I have a view that is use in every pages.
The view is to set default styles and Javascript for the site. This include  a JavaScript variable for the site URL

PHP Code:
<script type="text/javascript">
 
   var BASE_URL "<?php echo base_url().index_page();?>";
</
script

Then use the variable to make the URL
Code:
$(document).ready(function() {
    $(document).delegate('img[data-toggle=\'image\']', 'click', function() {
        $('#modal-image').remove();
        $.ajax({
            url: BASE_URL + '/filemanger', // full URL
            dataType: 'html',
            success: function(html) {
                $('body').append('<div id="modal-image" class="modal">' + html + '</div>');
    
                $('#modal-image').modal('show');
            }
        });
    });    
});  

I hope this helps.

I can access the url in browser but when use ajax says network error even though url is correct now.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
RE: Setting url in a .js file - by salain - 11-01-2016, 10:45 PM
RE: Setting url in a .js file - by wolfgang1983 - 11-02-2016, 12:34 AM
RE: Setting url in a .js file - by salain - 11-02-2016, 02:40 AM
RE: Setting url in a .js file - by InsiteFX - 11-02-2016, 03:07 AM
RE: Setting url in a .js file - by wolfgang1983 - 11-02-2016, 03:20 AM
RE: Setting url in a .js file - by InsiteFX - 11-02-2016, 09:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB