I wanna structure my JS Code like the MVC Pattern.
Always when a site is loaded like index.php, a Controller Object will be created. And a function is called.
In the Controller.js File this function create a Model Object.
But I get an error which says that Model isn't a function.
File index.php
<script>
var mController = new Controller();
mController.load();
</script>
File Controller.js
function Controller()
{
console.log('IN CONTROLLER'); // OUTPUT: IN CONTROLLER
this.load = function()
{
var mModel = new Model(); // OUTPUT: Model is not a function
mModel.load();
}
}
File Model.js
function Model()
{
this.load = function() { ... }
}
UPDATE: Error were the same name of variable and function.