Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

[Solved] Setting url in a .js file

$
0
0
I have set my url in a js file


Code:
assets

assets > jquery > common.js



And I have a controller called Filemanager.php


Code:
application

application > controllers > Filemanager.php


When I try click on my button which trys to launch modal. It gives the wrong location and a 404 error


The url out puts

Code:
http://localhost/project-1/question/filemanager

How ever should only produce

Code:
http://localhost/project-1/filemanager


assets > jquery > common.js


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


Routes.php


Code:
$route['filemanager'] = 'filemanager/index';


Any idea in how to make sure it gets the right url I cannot use base_url in a js file.

.png   filemanager.png (Size: 14.4 KB / Downloads: 11)

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>