title: Load view with onclick event
body: <p>I have the following view <img src="https://i.stack.imgur.com/fIu9C.png" alt="enter image description here"></p>
  
  <p>Which is genererated from javascript:</p>
  
  <pre><code>//Zητάει τις κατηγορίες από την βάση
      var appendCategoreis = function(categories){
      $.ajax({
          url: "http://localhost/perouka/index.php/MainController/getCategories",
          dataType: 'json',
          success: function(data) {
              $.each(data,function(item){
                  var node = $(categories);
  
                  node.find(".category-title").html(data[item].Name);
                  node.find(".category-icon").css({"background-image":"url("+data[item].Icon+")"});
                  node.attr("onclick","window.location.href='http://localhost/perouka2/perouka/index.php/ResultsController/loadView'");
                  $(".categories").append(node);
  
  
              });
          },
          error: function(e) {
              console.log(e);
          }
      });
      }
  
      //Φορτώνει το template για της κατηγορίες
      $.get( "application/views/templates/category.html", appendCategoreis);
  </code></pre>
  
  <p>The important line is <code>node.attr("onclick","window.location.href='http://localhost/perouka2/perouka/index.php/ResultsController/loadView'");</code>where I add an onlick event on each of these categories. This calls my controller:</p>
  
  <pre><code>class ResultsController extends CI_Controller
  {
  
  
      public function __construct()
      {
          parent::__construct();
      }
  
      public function loadView(){
          $this-&gt;load-&gt;view('navbar');
      }
  
  }
  </code></pre>
  
  <p>When I run the above and click on one I am getting a <code>FileError: 'http://localhost/perouka2/perouka/index.php/ResultsController/css/navbar.less' wasn't found (404)</code> </p>
  
  <p>What is the best practise for loading views on onclick events? </p>